{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-services/syncto/pulls/comments/41127670","id":41127670,"diff_hunk":"@@ -45,15 +48,19 @@ def build_sync_client(request):\n     cache_key = 'credentials_%s' % utils.hmac_digest(hmac_secret,\n                                                      bid_assertion)\n \n-    credentials = cache.get(cache_key)\n+    encrypted_credentials = cache.get(cache_key)\n \n-    if not credentials:\n+    if not encrypted_credentials:\n         ttl = int(settings['syncto.cache_credentials_ttl_seconds'])\n         tokenserver = TokenserverClient(bid_assertion, client_state)\n         if statsd:\n             statsd.watch_execution_time(tokenserver, prefix=\"tokenserver\")\n         credentials = tokenserver.get_hawk_credentials(duration=ttl)\n-        cache.set(cache_key, credentials, ttl)\n+        encrypted = encrypt(json.dumps(credentials), client_state, hmac_secret)\n+        cache.set(cache_key, encrypted, ttl)","path":"syncto/authentication.py","position":30,"original_position":30,"commit_id":"f53111a00ebc68478f8cbbbcc3718dfaba14c58a","original_commit_id":"49225828c41ba8eb3d7d99e32e7ba3712a51d9db","user":{"login":"Natim","id":229453,"avatar_url":"https://avatars.githubusercontent.com/u/229453?v=3","gravatar_id":"","url":"https://api.github.com/users/Natim","html_url":"https://github.com/Natim","followers_url":"https://api.github.com/users/Natim/followers","following_url":"https://api.github.com/users/Natim/following{/other_user}","gists_url":"https://api.github.com/users/Natim/gists{/gist_id}","starred_url":"https://api.github.com/users/Natim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Natim/subscriptions","organizations_url":"https://api.github.com/users/Natim/orgs","repos_url":"https://api.github.com/users/Natim/repos","events_url":"https://api.github.com/users/Natim/events{/privacy}","received_events_url":"https://api.github.com/users/Natim/received_events","type":"User","site_admin":false},"body":"I have added the two spec tests here: https://github.com/mozilla-services/syncto/pull/30/files#diff-54b1188b370166a8a9ba337f3dce6711R66","created_at":"2015-10-05T10:02:40Z","updated_at":"2015-10-05T10:02:40Z","html_url":"https://github.com/mozilla-services/syncto/pull/30#discussion_r41127670","pull_request_url":"https://api.github.com/repos/mozilla-services/syncto/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/mozilla-services/syncto/pulls/comments/41127670"},"html":{"href":"https://github.com/mozilla-services/syncto/pull/30#discussion_r41127670"},"pull_request":{"href":"https://api.github.com/repos/mozilla-services/syncto/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-services/syncto/pulls/30","id":46757494,"html_url":"https://github.com/mozilla-services/syncto/pull/30","diff_url":"https://github.com/mozilla-services/syncto/pull/30.diff","patch_url":"https://github.com/mozilla-services/syncto/pull/30.patch","issue_url":"https://api.github.com/repos/mozilla-services/syncto/issues/30","number":30,"state":"open","locked":false,"title":"Encrypt credentials with X-Client-State before caching the credentials","user":{"login":"Natim","id":229453,"avatar_url":"https://avatars.githubusercontent.com/u/229453?v=3","gravatar_id":"","url":"https://api.github.com/users/Natim","html_url":"https://github.com/Natim","followers_url":"https://api.github.com/users/Natim/followers","following_url":"https://api.github.com/users/Natim/following{/other_user}","gists_url":"https://api.github.com/users/Natim/gists{/gist_id}","starred_url":"https://api.github.com/users/Natim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Natim/subscriptions","organizations_url":"https://api.github.com/users/Natim/orgs","repos_url":"https://api.github.com/users/Natim/repos","events_url":"https://api.github.com/users/Natim/events{/privacy}","received_events_url":"https://api.github.com/users/Natim/received_events","type":"User","site_admin":false},"body":"Use PyNaCl: https://github.com/dstufft/pynacl","created_at":"2015-10-05T09:06:30Z","updated_at":"2015-10-05T10:02:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"408f819d823d2f9fdfe69e36b95f004fcf41ec0f","assignee":{"login":"Natim","id":229453,"avatar_url":"https://avatars.githubusercontent.com/u/229453?v=3","gravatar_id":"","url":"https://api.github.com/users/Natim","html_url":"https://github.com/Natim","followers_url":"https://api.github.com/users/Natim/followers","following_url":"https://api.github.com/users/Natim/following{/other_user}","gists_url":"https://api.github.com/users/Natim/gists{/gist_id}","starred_url":"https://api.github.com/users/Natim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Natim/subscriptions","organizations_url":"https://api.github.com/users/Natim/orgs","repos_url":"https://api.github.com/users/Natim/repos","events_url":"https://api.github.com/users/Natim/events{/privacy}","received_events_url":"https://api.github.com/users/Natim/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mozilla-services/syncto/milestones/2","html_url":"https://github.com/mozilla-services/syncto/milestones/Syncto%201.0","labels_url":"https://api.github.com/repos/mozilla-services/syncto/milestones/2/labels","id":1337498,"number":2,"title":"Syncto 1.0","description":"","creator":{"login":"Natim","id":229453,"avatar_url":"https://avatars.githubusercontent.com/u/229453?v=3","gravatar_id":"","url":"https://api.github.com/users/Natim","html_url":"https://github.com/Natim","followers_url":"https://api.github.com/users/Natim/followers","following_url":"https://api.github.com/users/Natim/following{/other_user}","gists_url":"https://api.github.com/users/Natim/gists{/gist_id}","starred_url":"https://api.github.com/users/Natim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Natim/subscriptions","organizations_url":"https://api.github.com/users/Natim/orgs","repos_url":"https://api.github.com/users/Natim/repos","events_url":"https://api.github.com/users/Natim/events{/privacy}","received_events_url":"https://api.github.com/users/Natim/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2015-10-05T07:06:20Z","updated_at":"2015-10-05T07:06:27Z","due_on":"2015-10-08T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/mozilla-services/syncto/pulls/30/commits","review_comments_url":"https://api.github.com/repos/mozilla-services/syncto/pulls/30/comments","review_comment_url":"https://api.github.com/repos/mozilla-services/syncto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-services/syncto/issues/30/comments","statuses_url":"https://api.github.com/repos/mozilla-services/syncto/statuses/f53111a00ebc68478f8cbbbcc3718dfaba14c58a","head":{"label":"mozilla-services:30-encrypt-credentials-in-cache","ref":"30-encrypt-credentials-in-cache","sha":"f53111a00ebc68478f8cbbbcc3718dfaba14c58a","user":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"repo":{"id":39374287,"name":"syncto","full_name":"mozilla-services/syncto","owner":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-services/syncto","description":"Sync to Kinto bridge (read and write data from/to sync with the Kinto interface)","fork":false,"url":"https://api.github.com/repos/mozilla-services/syncto","forks_url":"https://api.github.com/repos/mozilla-services/syncto/forks","keys_url":"https://api.github.com/repos/mozilla-services/syncto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-services/syncto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-services/syncto/teams","hooks_url":"https://api.github.com/repos/mozilla-services/syncto/hooks","issue_events_url":"https://api.github.com/repos/mozilla-services/syncto/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-services/syncto/events","assignees_url":"https://api.github.com/repos/mozilla-services/syncto/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-services/syncto/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-services/syncto/tags","blobs_url":"https://api.github.com/repos/mozilla-services/syncto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-services/syncto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-services/syncto/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-services/syncto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-services/syncto/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-services/syncto/languages","stargazers_url":"https://api.github.com/repos/mozilla-services/syncto/stargazers","contributors_url":"https://api.github.com/repos/mozilla-services/syncto/contributors","subscribers_url":"https://api.github.com/repos/mozilla-services/syncto/subscribers","subscription_url":"https://api.github.com/repos/mozilla-services/syncto/subscription","commits_url":"https://api.github.com/repos/mozilla-services/syncto/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-services/syncto/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-services/syncto/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-services/syncto/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-services/syncto/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-services/syncto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-services/syncto/merges","archive_url":"https://api.github.com/repos/mozilla-services/syncto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-services/syncto/downloads","issues_url":"https://api.github.com/repos/mozilla-services/syncto/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-services/syncto/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-services/syncto/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-services/syncto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-services/syncto/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-services/syncto/releases{/id}","created_at":"2015-07-20T09:14:26Z","updated_at":"2015-09-10T07:37:27Z","pushed_at":"2015-10-05T10:01:30Z","git_url":"git://github.com/mozilla-services/syncto.git","ssh_url":"git@github.com:mozilla-services/syncto.git","clone_url":"https://github.com/mozilla-services/syncto.git","svn_url":"https://github.com/mozilla-services/syncto","homepage":"https://wiki.mozilla.org/Firefox_OS/Syncto","size":717,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"mozilla-services:master","ref":"master","sha":"2c584172db9d54c11c7fcf1872d6fc86abc50054","user":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"repo":{"id":39374287,"name":"syncto","full_name":"mozilla-services/syncto","owner":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-services/syncto","description":"Sync to Kinto bridge (read and write data from/to sync with the Kinto interface)","fork":false,"url":"https://api.github.com/repos/mozilla-services/syncto","forks_url":"https://api.github.com/repos/mozilla-services/syncto/forks","keys_url":"https://api.github.com/repos/mozilla-services/syncto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-services/syncto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-services/syncto/teams","hooks_url":"https://api.github.com/repos/mozilla-services/syncto/hooks","issue_events_url":"https://api.github.com/repos/mozilla-services/syncto/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-services/syncto/events","assignees_url":"https://api.github.com/repos/mozilla-services/syncto/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-services/syncto/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-services/syncto/tags","blobs_url":"https://api.github.com/repos/mozilla-services/syncto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-services/syncto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-services/syncto/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-services/syncto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-services/syncto/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-services/syncto/languages","stargazers_url":"https://api.github.com/repos/mozilla-services/syncto/stargazers","contributors_url":"https://api.github.com/repos/mozilla-services/syncto/contributors","subscribers_url":"https://api.github.com/repos/mozilla-services/syncto/subscribers","subscription_url":"https://api.github.com/repos/mozilla-services/syncto/subscription","commits_url":"https://api.github.com/repos/mozilla-services/syncto/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-services/syncto/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-services/syncto/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-services/syncto/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-services/syncto/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-services/syncto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-services/syncto/merges","archive_url":"https://api.github.com/repos/mozilla-services/syncto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-services/syncto/downloads","issues_url":"https://api.github.com/repos/mozilla-services/syncto/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-services/syncto/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-services/syncto/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-services/syncto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-services/syncto/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-services/syncto/releases{/id}","created_at":"2015-07-20T09:14:26Z","updated_at":"2015-09-10T07:37:27Z","pushed_at":"2015-10-05T10:01:30Z","git_url":"git://github.com/mozilla-services/syncto.git","ssh_url":"git@github.com:mozilla-services/syncto.git","clone_url":"https://github.com/mozilla-services/syncto.git","svn_url":"https://github.com/mozilla-services/syncto","homepage":"https://wiki.mozilla.org/Firefox_OS/Syncto","size":717,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-services/syncto/pulls/30"},"html":{"href":"https://github.com/mozilla-services/syncto/pull/30"},"issue":{"href":"https://api.github.com/repos/mozilla-services/syncto/issues/30"},"comments":{"href":"https://api.github.com/repos/mozilla-services/syncto/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-services/syncto/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-services/syncto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-services/syncto/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-services/syncto/statuses/f53111a00ebc68478f8cbbbcc3718dfaba14c58a"}}}}