{"action":"created","comment":{"url":"https://api.github.com/repos/travis-ci/travis-build/pulls/comments/72297827","id":72297827,"diff_hunk":"@@ -0,0 +1,41 @@\n+require 'travis/build/addons/base'\n+require 'jwt'\n+\n+module Travis\n+  module Build\n+    class Addons\n+      class Jwt < Base\n+        SUPER_USER_SAFE = true\n+\n+        def before_before_script\n+          secrets = nil\n+          if config.is_a?(String)\n+            secrets = [config]\n+          else\n+            secrets = config.values\n+          end\n+\n+          tokens = {}\n+          secrets.each do |secret|\n+            key, secret = secret.split('=').map(&:strip)\n+            pull_request = self.data.pull_request ? self.data.pull_request : \"\"\n+            now = Time.now.to_i()\n+            payload = {\"iss\" => \"travis-ci.org\",\n+                      \"slug\" => self.data.slug,\n+                      \"pull-request\" => pull_request,\n+                      \"exp\" => now+5400,\n+                      \"iat\" => now}\n+            token = JWT.encode(payload, secret)","path":"lib/travis/build/addons/jwt.rb","position":30,"original_position":28,"commit_id":"b5a1fb6de21ee237ca552a761d612899bf11ee0f","original_commit_id":"bb16a55b414a22dd66ab41c924251d85a665efff","user":{"login":"BanzaiMan","id":25666,"avatar_url":"https://avatars.githubusercontent.com/u/25666?v=3","gravatar_id":"","url":"https://api.github.com/users/BanzaiMan","html_url":"https://github.com/BanzaiMan","followers_url":"https://api.github.com/users/BanzaiMan/followers","following_url":"https://api.github.com/users/BanzaiMan/following{/other_user}","gists_url":"https://api.github.com/users/BanzaiMan/gists{/gist_id}","starred_url":"https://api.github.com/users/BanzaiMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BanzaiMan/subscriptions","organizations_url":"https://api.github.com/users/BanzaiMan/orgs","repos_url":"https://api.github.com/users/BanzaiMan/repos","events_url":"https://api.github.com/users/BanzaiMan/events{/privacy}","received_events_url":"https://api.github.com/users/BanzaiMan/received_events","type":"User","site_admin":false},"body":"You can stub `JWT.encode` and raise an exception.","created_at":"2016-07-26T17:30:52Z","updated_at":"2016-07-26T17:30:52Z","html_url":"https://github.com/travis-ci/travis-build/pull/356#discussion_r72297827","pull_request_url":"https://api.github.com/repos/travis-ci/travis-build/pulls/356","_links":{"self":{"href":"https://api.github.com/repos/travis-ci/travis-build/pulls/comments/72297827"},"html":{"href":"https://github.com/travis-ci/travis-build/pull/356#discussion_r72297827"},"pull_request":{"href":"https://api.github.com/repos/travis-ci/travis-build/pulls/356"}}},"pull_request":{"url":"https://api.github.com/repos/travis-ci/travis-build/pulls/356","id":25945478,"html_url":"https://github.com/travis-ci/travis-build/pull/356","diff_url":"https://github.com/travis-ci/travis-build/pull/356.diff","patch_url":"https://github.com/travis-ci/travis-build/pull/356.patch","issue_url":"https://api.github.com/repos/travis-ci/travis-build/issues/356","number":356,"state":"open","locked":false,"title":"JWT addon","user":{"login":"sebv","id":418288,"avatar_url":"https://avatars.githubusercontent.com/u/418288?v=3","gravatar_id":"","url":"https://api.github.com/users/sebv","html_url":"https://github.com/sebv","followers_url":"https://api.github.com/users/sebv/followers","following_url":"https://api.github.com/users/sebv/following{/other_user}","gists_url":"https://api.github.com/users/sebv/gists{/gist_id}","starred_url":"https://api.github.com/users/sebv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebv/subscriptions","organizations_url":"https://api.github.com/users/sebv/orgs","repos_url":"https://api.github.com/users/sebv/repos","events_url":"https://api.github.com/users/sebv/events{/privacy}","received_events_url":"https://api.github.com/users/sebv/received_events","type":"User","site_admin":false},"body":"JWT token authentication for PR.\r\n\r\nUsers need to add this to `.travis.yml`.\r\n\r\n```\r\naddons:\r\n  jwt: \r\n     secure: <SAUCE_ACCESS_KEY=123456789 encrypted> \r\n```\r\n\r\nThe JWT addon will then create a time-limited JWT token and export it to the SAUCE_ACCESS_KEY environment variable.\r\n\r\nThis is not specific to sauce labs several services may be configured, for instance:\r\n```\r\naddons:\r\n  jwt:\r\n     saucelabs:\r\n        secure: <SAUCE_ACCESS_KEY=123456789 encrypted>\r\n     moonwalk:\r\n        secure: <MOONWALK_SECRET=123456789 encrypted>\r\n```\r\nIn this case 2 tokens will be generated, one in the SAUCE_ACCESS_KEY env variable, the other in MOONWALK_SECRET.\r\n","created_at":"2014-12-12T01:04:40Z","updated_at":"2016-07-26T17:30:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6982e49f4d338dacbba16e2491e6c9b78cfa62c","assignee":{"login":"BanzaiMan","id":25666,"avatar_url":"https://avatars.githubusercontent.com/u/25666?v=3","gravatar_id":"","url":"https://api.github.com/users/BanzaiMan","html_url":"https://github.com/BanzaiMan","followers_url":"https://api.github.com/users/BanzaiMan/followers","following_url":"https://api.github.com/users/BanzaiMan/following{/other_user}","gists_url":"https://api.github.com/users/BanzaiMan/gists{/gist_id}","starred_url":"https://api.github.com/users/BanzaiMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BanzaiMan/subscriptions","organizations_url":"https://api.github.com/users/BanzaiMan/orgs","repos_url":"https://api.github.com/users/BanzaiMan/repos","events_url":"https://api.github.com/users/BanzaiMan/events{/privacy}","received_events_url":"https://api.github.com/users/BanzaiMan/received_events","type":"User","site_admin":false},"assignees":[{"login":"BanzaiMan","id":25666,"avatar_url":"https://avatars.githubusercontent.com/u/25666?v=3","gravatar_id":"","url":"https://api.github.com/users/BanzaiMan","html_url":"https://github.com/BanzaiMan","followers_url":"https://api.github.com/users/BanzaiMan/followers","following_url":"https://api.github.com/users/BanzaiMan/following{/other_user}","gists_url":"https://api.github.com/users/BanzaiMan/gists{/gist_id}","starred_url":"https://api.github.com/users/BanzaiMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BanzaiMan/subscriptions","organizations_url":"https://api.github.com/users/BanzaiMan/orgs","repos_url":"https://api.github.com/users/BanzaiMan/repos","events_url":"https://api.github.com/users/BanzaiMan/events{/privacy}","received_events_url":"https://api.github.com/users/BanzaiMan/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/travis-ci/travis-build/pulls/356/commits","review_comments_url":"https://api.github.com/repos/travis-ci/travis-build/pulls/356/comments","review_comment_url":"https://api.github.com/repos/travis-ci/travis-build/pulls/comments{/number}","comments_url":"https://api.github.com/repos/travis-ci/travis-build/issues/356/comments","statuses_url":"https://api.github.com/repos/travis-ci/travis-build/statuses/b5a1fb6de21ee237ca552a761d612899bf11ee0f","head":{"label":"saucelabs:jwt","ref":"jwt","sha":"b5a1fb6de21ee237ca552a761d612899bf11ee0f","user":{"login":"saucelabs","id":88837,"avatar_url":"https://avatars.githubusercontent.com/u/88837?v=3","gravatar_id":"","url":"https://api.github.com/users/saucelabs","html_url":"https://github.com/saucelabs","followers_url":"https://api.github.com/users/saucelabs/followers","following_url":"https://api.github.com/users/saucelabs/following{/other_user}","gists_url":"https://api.github.com/users/saucelabs/gists{/gist_id}","starred_url":"https://api.github.com/users/saucelabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saucelabs/subscriptions","organizations_url":"https://api.github.com/users/saucelabs/orgs","repos_url":"https://api.github.com/users/saucelabs/repos","events_url":"https://api.github.com/users/saucelabs/events{/privacy}","received_events_url":"https://api.github.com/users/saucelabs/received_events","type":"Organization","site_admin":false},"repo":{"id":27843491,"name":"travis-build","full_name":"saucelabs/travis-build","owner":{"login":"saucelabs","id":88837,"avatar_url":"https://avatars.githubusercontent.com/u/88837?v=3","gravatar_id":"","url":"https://api.github.com/users/saucelabs","html_url":"https://github.com/saucelabs","followers_url":"https://api.github.com/users/saucelabs/followers","following_url":"https://api.github.com/users/saucelabs/following{/other_user}","gists_url":"https://api.github.com/users/saucelabs/gists{/gist_id}","starred_url":"https://api.github.com/users/saucelabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saucelabs/subscriptions","organizations_url":"https://api.github.com/users/saucelabs/orgs","repos_url":"https://api.github.com/users/saucelabs/repos","events_url":"https://api.github.com/users/saucelabs/events{/privacy}","received_events_url":"https://api.github.com/users/saucelabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/saucelabs/travis-build","description":"Encapsulates a build, used by travis-worker","fork":true,"url":"https://api.github.com/repos/saucelabs/travis-build","forks_url":"https://api.github.com/repos/saucelabs/travis-build/forks","keys_url":"https://api.github.com/repos/saucelabs/travis-build/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saucelabs/travis-build/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saucelabs/travis-build/teams","hooks_url":"https://api.github.com/repos/saucelabs/travis-build/hooks","issue_events_url":"https://api.github.com/repos/saucelabs/travis-build/issues/events{/number}","events_url":"https://api.github.com/repos/saucelabs/travis-build/events","assignees_url":"https://api.github.com/repos/saucelabs/travis-build/assignees{/user}","branches_url":"https://api.github.com/repos/saucelabs/travis-build/branches{/branch}","tags_url":"https://api.github.com/repos/saucelabs/travis-build/tags","blobs_url":"https://api.github.com/repos/saucelabs/travis-build/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saucelabs/travis-build/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saucelabs/travis-build/git/refs{/sha}","trees_url":"https://api.github.com/repos/saucelabs/travis-build/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saucelabs/travis-build/statuses/{sha}","languages_url":"https://api.github.com/repos/saucelabs/travis-build/languages","stargazers_url":"https://api.github.com/repos/saucelabs/travis-build/stargazers","contributors_url":"https://api.github.com/repos/saucelabs/travis-build/contributors","subscribers_url":"https://api.github.com/repos/saucelabs/travis-build/subscribers","subscription_url":"https://api.github.com/repos/saucelabs/travis-build/subscription","commits_url":"https://api.github.com/repos/saucelabs/travis-build/commits{/sha}","git_commits_url":"https://api.github.com/repos/saucelabs/travis-build/git/commits{/sha}","comments_url":"https://api.github.com/repos/saucelabs/travis-build/comments{/number}","issue_comment_url":"https://api.github.com/repos/saucelabs/travis-build/issues/comments{/number}","contents_url":"https://api.github.com/repos/saucelabs/travis-build/contents/{+path}","compare_url":"https://api.github.com/repos/saucelabs/travis-build/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saucelabs/travis-build/merges","archive_url":"https://api.github.com/repos/saucelabs/travis-build/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saucelabs/travis-build/downloads","issues_url":"https://api.github.com/repos/saucelabs/travis-build/issues{/number}","pulls_url":"https://api.github.com/repos/saucelabs/travis-build/pulls{/number}","milestones_url":"https://api.github.com/repos/saucelabs/travis-build/milestones{/number}","notifications_url":"https://api.github.com/repos/saucelabs/travis-build/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saucelabs/travis-build/labels{/name}","releases_url":"https://api.github.com/repos/saucelabs/travis-build/releases{/id}","deployments_url":"https://api.github.com/repos/saucelabs/travis-build/deployments","created_at":"2014-12-10T22:47:26Z","updated_at":"2014-12-10T22:47:27Z","pushed_at":"2016-07-26T15:51:47Z","git_url":"git://github.com/saucelabs/travis-build.git","ssh_url":"git@github.com:saucelabs/travis-build.git","clone_url":"https://github.com/saucelabs/travis-build.git","svn_url":"https://github.com/saucelabs/travis-build","homepage":"","size":4143,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"travis-ci:master","ref":"master","sha":"0766724c08aadfb22ad8c1f65d949151724a0edf","user":{"login":"travis-ci","id":639823,"avatar_url":"https://avatars.githubusercontent.com/u/639823?v=3","gravatar_id":"","url":"https://api.github.com/users/travis-ci","html_url":"https://github.com/travis-ci","followers_url":"https://api.github.com/users/travis-ci/followers","following_url":"https://api.github.com/users/travis-ci/following{/other_user}","gists_url":"https://api.github.com/users/travis-ci/gists{/gist_id}","starred_url":"https://api.github.com/users/travis-ci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travis-ci/subscriptions","organizations_url":"https://api.github.com/users/travis-ci/orgs","repos_url":"https://api.github.com/users/travis-ci/repos","events_url":"https://api.github.com/users/travis-ci/events{/privacy}","received_events_url":"https://api.github.com/users/travis-ci/received_events","type":"Organization","site_admin":false},"repo":{"id":2508083,"name":"travis-build","full_name":"travis-ci/travis-build","owner":{"login":"travis-ci","id":639823,"avatar_url":"https://avatars.githubusercontent.com/u/639823?v=3","gravatar_id":"","url":"https://api.github.com/users/travis-ci","html_url":"https://github.com/travis-ci","followers_url":"https://api.github.com/users/travis-ci/followers","following_url":"https://api.github.com/users/travis-ci/following{/other_user}","gists_url":"https://api.github.com/users/travis-ci/gists{/gist_id}","starred_url":"https://api.github.com/users/travis-ci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travis-ci/subscriptions","organizations_url":"https://api.github.com/users/travis-ci/orgs","repos_url":"https://api.github.com/users/travis-ci/repos","events_url":"https://api.github.com/users/travis-ci/events{/privacy}","received_events_url":"https://api.github.com/users/travis-ci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/travis-ci/travis-build","description":".travis.yml => build.sh converter","fork":false,"url":"https://api.github.com/repos/travis-ci/travis-build","forks_url":"https://api.github.com/repos/travis-ci/travis-build/forks","keys_url":"https://api.github.com/repos/travis-ci/travis-build/keys{/key_id}","collaborators_url":"https://api.github.com/repos/travis-ci/travis-build/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/travis-ci/travis-build/teams","hooks_url":"https://api.github.com/repos/travis-ci/travis-build/hooks","issue_events_url":"https://api.github.com/repos/travis-ci/travis-build/issues/events{/number}","events_url":"https://api.github.com/repos/travis-ci/travis-build/events","assignees_url":"https://api.github.com/repos/travis-ci/travis-build/assignees{/user}","branches_url":"https://api.github.com/repos/travis-ci/travis-build/branches{/branch}","tags_url":"https://api.github.com/repos/travis-ci/travis-build/tags","blobs_url":"https://api.github.com/repos/travis-ci/travis-build/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/travis-ci/travis-build/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/travis-ci/travis-build/git/refs{/sha}","trees_url":"https://api.github.com/repos/travis-ci/travis-build/git/trees{/sha}","statuses_url":"https://api.github.com/repos/travis-ci/travis-build/statuses/{sha}","languages_url":"https://api.github.com/repos/travis-ci/travis-build/languages","stargazers_url":"https://api.github.com/repos/travis-ci/travis-build/stargazers","contributors_url":"https://api.github.com/repos/travis-ci/travis-build/contributors","subscribers_url":"https://api.github.com/repos/travis-ci/travis-build/subscribers","subscription_url":"https://api.github.com/repos/travis-ci/travis-build/subscription","commits_url":"https://api.github.com/repos/travis-ci/travis-build/commits{/sha}","git_commits_url":"https://api.github.com/repos/travis-ci/travis-build/git/commits{/sha}","comments_url":"https://api.github.com/repos/travis-ci/travis-build/comments{/number}","issue_comment_url":"https://api.github.com/repos/travis-ci/travis-build/issues/comments{/number}","contents_url":"https://api.github.com/repos/travis-ci/travis-build/contents/{+path}","compare_url":"https://api.github.com/repos/travis-ci/travis-build/compare/{base}...{head}","merges_url":"https://api.github.com/repos/travis-ci/travis-build/merges","archive_url":"https://api.github.com/repos/travis-ci/travis-build/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/travis-ci/travis-build/downloads","issues_url":"https://api.github.com/repos/travis-ci/travis-build/issues{/number}","pulls_url":"https://api.github.com/repos/travis-ci/travis-build/pulls{/number}","milestones_url":"https://api.github.com/repos/travis-ci/travis-build/milestones{/number}","notifications_url":"https://api.github.com/repos/travis-ci/travis-build/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/travis-ci/travis-build/labels{/name}","releases_url":"https://api.github.com/repos/travis-ci/travis-build/releases{/id}","deployments_url":"https://api.github.com/repos/travis-ci/travis-build/deployments","created_at":"2011-10-03T21:46:00Z","updated_at":"2016-07-21T14:43:16Z","pushed_at":"2016-07-26T16:43:53Z","git_url":"git://github.com/travis-ci/travis-build.git","ssh_url":"git@github.com:travis-ci/travis-build.git","clone_url":"https://github.com/travis-ci/travis-build.git","svn_url":"https://github.com/travis-ci/travis-build","homepage":"","size":6212,"stargazers_count":250,"watchers_count":250,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":238,"mirror_url":null,"open_issues_count":36,"forks":238,"open_issues":36,"watchers":250,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/travis-ci/travis-build/pulls/356"},"html":{"href":"https://github.com/travis-ci/travis-build/pull/356"},"issue":{"href":"https://api.github.com/repos/travis-ci/travis-build/issues/356"},"comments":{"href":"https://api.github.com/repos/travis-ci/travis-build/issues/356/comments"},"review_comments":{"href":"https://api.github.com/repos/travis-ci/travis-build/pulls/356/comments"},"review_comment":{"href":"https://api.github.com/repos/travis-ci/travis-build/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/travis-ci/travis-build/pulls/356/commits"},"statuses":{"href":"https://api.github.com/repos/travis-ci/travis-build/statuses/b5a1fb6de21ee237ca552a761d612899bf11ee0f"}}}}
{"actor":{"display_login":"BanzaiMan"}}