{"action":"created","comment":{"url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/comments/73637718","id":73637718,"diff_hunk":"@@ -0,0 +1,30 @@\n+from functools import wraps\n+\n+from flask import Response, current_app, request\n+\n+import atlassian_jwt_auth\n+from atlassian_jwt_auth.contrib.flask_app.utils import parse_jwt\n+\n+\n+def requires_asap(f):\n+    \"\"\"\n+    Wrapper for Flask endpoints to make them require authentication to access.\n+    \"\"\"\n+\n+    @wraps(f)\n+    def decorated(*args, **kwargs):\n+        verifier = _get_verifier()\n+        auth = request.headers.get('Authorization')\n+        if not auth or not parse_jwt(verifier, auth.split(\" \")[1]):\n+            return Response('Unauthorized', 401)\n+        return f(*args, **kwargs)\n+    return decorated\n+\n+\n+def _get_verifier():\n+    \"\"\"Returns a verifier based on config.asap['PUBLICKEY_REPOSITORY']\"\"\"","path":"atlassian_jwt_auth/contrib/flask_app/decorators.py","position":25,"original_position":25,"commit_id":"60ba391f708a0a2086de908298000293340903a4","original_commit_id":"60ba391f708a0a2086de908298000293340903a4","user":{"login":"dbaxa","id":1684354,"avatar_url":"https://avatars.githubusercontent.com/u/1684354?v=3","gravatar_id":"","url":"https://api.github.com/users/dbaxa","html_url":"https://github.com/dbaxa","followers_url":"https://api.github.com/users/dbaxa/followers","following_url":"https://api.github.com/users/dbaxa/following{/other_user}","gists_url":"https://api.github.com/users/dbaxa/gists{/gist_id}","starred_url":"https://api.github.com/users/dbaxa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbaxa/subscriptions","organizations_url":"https://api.github.com/users/dbaxa/orgs","repos_url":"https://api.github.com/users/dbaxa/repos","events_url":"https://api.github.com/users/dbaxa/events{/privacy}","received_events_url":"https://api.github.com/users/dbaxa/received_events","type":"User","site_admin":false},"body":"Ah okay.","created_at":"2016-08-05T03:31:01Z","updated_at":"2016-08-05T03:31:01Z","html_url":"https://github.com/atlassian/asap-authentication-python/pull/29#discussion_r73637718","pull_request_url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/comments/73637718"},"html":{"href":"https://github.com/atlassian/asap-authentication-python/pull/29#discussion_r73637718"},"pull_request":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29","id":80085343,"html_url":"https://github.com/atlassian/asap-authentication-python/pull/29","diff_url":"https://github.com/atlassian/asap-authentication-python/pull/29.diff","patch_url":"https://github.com/atlassian/asap-authentication-python/pull/29.patch","issue_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/29","number":29,"state":"open","locked":false,"title":"Add contrib/flask_app.py with @requires_asap to support Flask + ASAP","user":{"login":"mark-adams","id":472350,"avatar_url":"https://avatars.githubusercontent.com/u/472350?v=3","gravatar_id":"","url":"https://api.github.com/users/mark-adams","html_url":"https://github.com/mark-adams","followers_url":"https://api.github.com/users/mark-adams/followers","following_url":"https://api.github.com/users/mark-adams/following{/other_user}","gists_url":"https://api.github.com/users/mark-adams/gists{/gist_id}","starred_url":"https://api.github.com/users/mark-adams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mark-adams/subscriptions","organizations_url":"https://api.github.com/users/mark-adams/orgs","repos_url":"https://api.github.com/users/mark-adams/repos","events_url":"https://api.github.com/users/mark-adams/events{/privacy}","received_events_url":"https://api.github.com/users/mark-adams/received_events","type":"User","site_admin":false},"body":"This is based loosely off of some code that was being used in a couple\r\nprojects and I think it makes sense to institutionalize some support for\r\nthe Python web frameworks in the centralized library\r\n\r\n- Added atlassian_jwt_auth.contrib.flask_app + tests\r\n- Renamed atlassian_jwt_auth.contrib.requests to requests_auth to avoid\r\n  issues with importing requests from other modules","created_at":"2016-08-04T14:12:50Z","updated_at":"2016-08-05T03:31:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c579db214f2fdb17bc28d2f6d33c54ac49cc3b3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29/commits","review_comments_url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29/comments","review_comment_url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/29/comments","statuses_url":"https://api.github.com/repos/atlassian/asap-authentication-python/statuses/60ba391f708a0a2086de908298000293340903a4","head":{"label":"atlassian:add-flask-contrib","ref":"add-flask-contrib","sha":"60ba391f708a0a2086de908298000293340903a4","user":{"login":"atlassian","id":168166,"avatar_url":"https://avatars.githubusercontent.com/u/168166?v=3","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"repo":{"id":41010216,"name":"asap-authentication-python","full_name":"atlassian/asap-authentication-python","owner":{"login":"atlassian","id":168166,"avatar_url":"https://avatars.githubusercontent.com/u/168166?v=3","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atlassian/asap-authentication-python","description":"This package provides a python implementation of the Atlassian Service to Service Authentication specification.","fork":false,"url":"https://api.github.com/repos/atlassian/asap-authentication-python","forks_url":"https://api.github.com/repos/atlassian/asap-authentication-python/forks","keys_url":"https://api.github.com/repos/atlassian/asap-authentication-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atlassian/asap-authentication-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atlassian/asap-authentication-python/teams","hooks_url":"https://api.github.com/repos/atlassian/asap-authentication-python/hooks","issue_events_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/events{/number}","events_url":"https://api.github.com/repos/atlassian/asap-authentication-python/events","assignees_url":"https://api.github.com/repos/atlassian/asap-authentication-python/assignees{/user}","branches_url":"https://api.github.com/repos/atlassian/asap-authentication-python/branches{/branch}","tags_url":"https://api.github.com/repos/atlassian/asap-authentication-python/tags","blobs_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atlassian/asap-authentication-python/statuses/{sha}","languages_url":"https://api.github.com/repos/atlassian/asap-authentication-python/languages","stargazers_url":"https://api.github.com/repos/atlassian/asap-authentication-python/stargazers","contributors_url":"https://api.github.com/repos/atlassian/asap-authentication-python/contributors","subscribers_url":"https://api.github.com/repos/atlassian/asap-authentication-python/subscribers","subscription_url":"https://api.github.com/repos/atlassian/asap-authentication-python/subscription","commits_url":"https://api.github.com/repos/atlassian/asap-authentication-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/atlassian/asap-authentication-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/atlassian/asap-authentication-python/contents/{+path}","compare_url":"https://api.github.com/repos/atlassian/asap-authentication-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atlassian/asap-authentication-python/merges","archive_url":"https://api.github.com/repos/atlassian/asap-authentication-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atlassian/asap-authentication-python/downloads","issues_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues{/number}","pulls_url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls{/number}","milestones_url":"https://api.github.com/repos/atlassian/asap-authentication-python/milestones{/number}","notifications_url":"https://api.github.com/repos/atlassian/asap-authentication-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atlassian/asap-authentication-python/labels{/name}","releases_url":"https://api.github.com/repos/atlassian/asap-authentication-python/releases{/id}","deployments_url":"https://api.github.com/repos/atlassian/asap-authentication-python/deployments","created_at":"2015-08-19T03:04:01Z","updated_at":"2016-07-20T21:15:56Z","pushed_at":"2016-08-04T15:29:09Z","git_url":"git://github.com/atlassian/asap-authentication-python.git","ssh_url":"git@github.com:atlassian/asap-authentication-python.git","clone_url":"https://github.com/atlassian/asap-authentication-python.git","svn_url":"https://github.com/atlassian/asap-authentication-python","homepage":"http://s2sauth.bitbucket.org/spec/","size":87,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":4,"default_branch":"master"}},"base":{"label":"atlassian:master","ref":"master","sha":"b75df5aeeb98c28ee82582deeb2b3a643e5317b2","user":{"login":"atlassian","id":168166,"avatar_url":"https://avatars.githubusercontent.com/u/168166?v=3","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"repo":{"id":41010216,"name":"asap-authentication-python","full_name":"atlassian/asap-authentication-python","owner":{"login":"atlassian","id":168166,"avatar_url":"https://avatars.githubusercontent.com/u/168166?v=3","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atlassian/asap-authentication-python","description":"This package provides a python implementation of the Atlassian Service to Service Authentication specification.","fork":false,"url":"https://api.github.com/repos/atlassian/asap-authentication-python","forks_url":"https://api.github.com/repos/atlassian/asap-authentication-python/forks","keys_url":"https://api.github.com/repos/atlassian/asap-authentication-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atlassian/asap-authentication-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atlassian/asap-authentication-python/teams","hooks_url":"https://api.github.com/repos/atlassian/asap-authentication-python/hooks","issue_events_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/events{/number}","events_url":"https://api.github.com/repos/atlassian/asap-authentication-python/events","assignees_url":"https://api.github.com/repos/atlassian/asap-authentication-python/assignees{/user}","branches_url":"https://api.github.com/repos/atlassian/asap-authentication-python/branches{/branch}","tags_url":"https://api.github.com/repos/atlassian/asap-authentication-python/tags","blobs_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atlassian/asap-authentication-python/statuses/{sha}","languages_url":"https://api.github.com/repos/atlassian/asap-authentication-python/languages","stargazers_url":"https://api.github.com/repos/atlassian/asap-authentication-python/stargazers","contributors_url":"https://api.github.com/repos/atlassian/asap-authentication-python/contributors","subscribers_url":"https://api.github.com/repos/atlassian/asap-authentication-python/subscribers","subscription_url":"https://api.github.com/repos/atlassian/asap-authentication-python/subscription","commits_url":"https://api.github.com/repos/atlassian/asap-authentication-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/atlassian/asap-authentication-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/atlassian/asap-authentication-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/atlassian/asap-authentication-python/contents/{+path}","compare_url":"https://api.github.com/repos/atlassian/asap-authentication-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atlassian/asap-authentication-python/merges","archive_url":"https://api.github.com/repos/atlassian/asap-authentication-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atlassian/asap-authentication-python/downloads","issues_url":"https://api.github.com/repos/atlassian/asap-authentication-python/issues{/number}","pulls_url":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls{/number}","milestones_url":"https://api.github.com/repos/atlassian/asap-authentication-python/milestones{/number}","notifications_url":"https://api.github.com/repos/atlassian/asap-authentication-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atlassian/asap-authentication-python/labels{/name}","releases_url":"https://api.github.com/repos/atlassian/asap-authentication-python/releases{/id}","deployments_url":"https://api.github.com/repos/atlassian/asap-authentication-python/deployments","created_at":"2015-08-19T03:04:01Z","updated_at":"2016-07-20T21:15:56Z","pushed_at":"2016-08-04T15:29:09Z","git_url":"git://github.com/atlassian/asap-authentication-python.git","ssh_url":"git@github.com:atlassian/asap-authentication-python.git","clone_url":"https://github.com/atlassian/asap-authentication-python.git","svn_url":"https://github.com/atlassian/asap-authentication-python","homepage":"http://s2sauth.bitbucket.org/spec/","size":87,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29"},"html":{"href":"https://github.com/atlassian/asap-authentication-python/pull/29"},"issue":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/29"},"comments":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/atlassian/asap-authentication-python/statuses/60ba391f708a0a2086de908298000293340903a4"}}}}
{"actor":{"display_login":"dbaxa"}}