Last active
December 27, 2015 18:17
-
-
Save masato/a2ae35e3b6359f21a9a1 to your computer and use it in GitHub Desktop.
Webhook as a ServiceでIoTのserverlessなバックエンド考える - Part 3: Webtask.ioでIDCFクラウド APIのセキュアな情報を扱う ref: http://qiita.com/masato/items/7a9fc2c9408fbb3ca5c0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ export PARAMETERIZED_TOKEN=$(curl -s https://webtask.it.auth0.com/api/tokens/issue -H "Authorization: Bearer eyJhbxxx" \ | |
-H "Content-Type: application/json" \ | |
--data-binary '{"url":"http://bit.ly/1wT1DOi","ectx":{"secret":"abc!123"}}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wt create https://raw.githubusercontent.com/auth0/wt-cli/master/sample-webtasks/mongodb.js \ | |
--name mongo \ | |
--secret MONGO_URL=mongodb://webtask:supersecret@ds047592.mongolab.com:47592/webtask-examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wt create startstop.js \ | |
--name startstop \ | |
--secret apikey=xxx \ | |
--secret secretkey=xxx \ | |
--secret endpoint=xxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://webtask.it.auth0.com/api/run/{コンテナ名}/startstop?webtask_no_cache=1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl "https://webtask.it.auth0.com/api/run/{コンテナ名}/startstop?webtask_no_cache=1&key={デフォルトのkey}&command=stop&id={仮想マシンのID}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"stopvirtualmachineresponse":{"jobid":"ad52d24e-xxx"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl "https://webtask.it.auth0.com/api/run/{コンテナ名}/startstop?webtask_no_cache=1&key={デフォルトのkey}&command=start&id={仮想マシンのID}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(context, cb) { | |
var MONGO_URL = context.data.MONGO_URL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(context, cb) { | |
var query = { | |
apiKey: context.data.apikey, | |
response: 'json', | |
command: context.data.command+'VirtualMachine', | |
id: context.data.id | |
} | |
query.signature = buildSignature(query, context.data.secretkey); | |
request.get({ | |
url: context.data.endpoint, | |
qs: query, | |
json: true | |
}, function (error, response, body) { | |
cb(null, body); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment