{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/build-relengapi/pulls/comments/27143346","id":27143346,"diff_hunk":"@@ -0,0 +1,41 @@\n+# This Source Code Form is subject to the terms of the Mozilla Public\n+# License, v. 2.0. If a copy of the MPL was not distributed with this\n+# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+from flask import current_app\n+from relengapi.blueprints.tokenauth import tables\n+from relengapi.lib import badpenny\n+\n+\n+@badpenny.periodic_task(3600)\n+def monitor_users(job_status):\n+    # for every user token, examine the token's permission map and the user's\n+    # permissions.  If the token has more permissions than the user, disable\n+    # the token.\n+    session = current_app.db.session('relengapi')\n+    for token in session.query(tables.Token).filter(tables.Token.typ == 'usr'):\n+        token_perms = set(token.permissions)\n+        user_perms = current_app.authz.get_user_permissions(token.user)\n+        print token_perms, user_perms\n+        if user_perms is None:\n+            print \"A\"\n+            disable = True\n+        else:\n+            if token_perms - user_perms:\n+                print \"B\"\n+                disable = True\n+            else:\n+                print \"C\"","path":"relengapi/blueprints/tokenauth/usermonitor.py","position":28,"original_position":28,"commit_id":"e67c0e03250be4d5f7e422de87478bb3849800a1","original_commit_id":"e67c0e03250be4d5f7e422de87478bb3849800a1","user":{"login":"Callek","id":1415602,"avatar_url":"https://avatars.githubusercontent.com/u/1415602?v=3","gravatar_id":"","url":"https://api.github.com/users/Callek","html_url":"https://github.com/Callek","followers_url":"https://api.github.com/users/Callek/followers","following_url":"https://api.github.com/users/Callek/following{/other_user}","gists_url":"https://api.github.com/users/Callek/gists{/gist_id}","starred_url":"https://api.github.com/users/Callek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Callek/subscriptions","organizations_url":"https://api.github.com/users/Callek/orgs","repos_url":"https://api.github.com/users/Callek/repos","events_url":"https://api.github.com/users/Callek/events{/privacy}","received_events_url":"https://api.github.com/users/Callek/received_events","type":"User","site_admin":false},"body":"A, B, C are debugging cruft I suspect, can you make this either a proper log entry, or remove them?","created_at":"2015-03-25T17:16:57Z","updated_at":"2015-03-25T17:16:57Z","html_url":"https://github.com/mozilla/build-relengapi/pull/186#discussion_r27143346","pull_request_url":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186","_links":{"self":{"href":"https://api.github.com/repos/mozilla/build-relengapi/pulls/comments/27143346"},"html":{"href":"https://github.com/mozilla/build-relengapi/pull/186#discussion_r27143346"},"pull_request":{"href":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186","id":30966956,"html_url":"https://github.com/mozilla/build-relengapi/pull/186","diff_url":"https://github.com/mozilla/build-relengapi/pull/186.diff","patch_url":"https://github.com/mozilla/build-relengapi/pull/186.patch","issue_url":"https://api.github.com/repos/mozilla/build-relengapi/issues/186","number":186,"state":"open","locked":false,"title":"Disable user tokens","user":{"login":"djmitche","id":28673,"avatar_url":"https://avatars.githubusercontent.com/u/28673?v=3","gravatar_id":"","url":"https://api.github.com/users/djmitche","html_url":"https://github.com/djmitche","followers_url":"https://api.github.com/users/djmitche/followers","following_url":"https://api.github.com/users/djmitche/following{/other_user}","gists_url":"https://api.github.com/users/djmitche/gists{/gist_id}","starred_url":"https://api.github.com/users/djmitche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djmitche/subscriptions","organizations_url":"https://api.github.com/users/djmitche/orgs","repos_url":"https://api.github.com/users/djmitche/repos","events_url":"https://api.github.com/users/djmitche/events{/privacy}","received_events_url":"https://api.github.com/users/djmitche/received_events","type":"User","site_admin":false},"body":"@callek, @jvehent \r\n\r\nThis, along with #175, should finish off the user-token work described in #163.","created_at":"2015-03-11T17:41:07Z","updated_at":"2015-03-25T17:16:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3ff8562b1a82cc98fec297094a0d74d9107409f","assignee":null,"milestone":{"url":"https://api.github.com/repos/mozilla/build-relengapi/milestones/3","html_url":"https://github.com/mozilla/build-relengapi/milestones/v2.0.0","labels_url":"https://api.github.com/repos/mozilla/build-relengapi/milestones/3/labels","id":906328,"number":3,"title":"v2.0.0","description":"Tools in place to support BuildAPI and other apps for migration.\r\n * Authentication","creator":{"login":"djmitche","id":28673,"avatar_url":"https://avatars.githubusercontent.com/u/28673?v=3","gravatar_id":"","url":"https://api.github.com/users/djmitche","html_url":"https://github.com/djmitche","followers_url":"https://api.github.com/users/djmitche/followers","following_url":"https://api.github.com/users/djmitche/following{/other_user}","gists_url":"https://api.github.com/users/djmitche/gists{/gist_id}","starred_url":"https://api.github.com/users/djmitche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djmitche/subscriptions","organizations_url":"https://api.github.com/users/djmitche/orgs","repos_url":"https://api.github.com/users/djmitche/repos","events_url":"https://api.github.com/users/djmitche/events{/privacy}","received_events_url":"https://api.github.com/users/djmitche/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":5,"state":"open","created_at":"2014-12-16T22:32:50Z","updated_at":"2015-03-24T23:26:24Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186/commits","review_comments_url":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186/comments","review_comment_url":"https://api.github.com/repos/mozilla/build-relengapi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/build-relengapi/issues/186/comments","statuses_url":"https://api.github.com/repos/mozilla/build-relengapi/statuses/e67c0e03250be4d5f7e422de87478bb3849800a1","head":{"label":"djmitche:disable-user-tokens","ref":"disable-user-tokens","sha":"e67c0e03250be4d5f7e422de87478bb3849800a1","user":{"login":"djmitche","id":28673,"avatar_url":"https://avatars.githubusercontent.com/u/28673?v=3","gravatar_id":"","url":"https://api.github.com/users/djmitche","html_url":"https://github.com/djmitche","followers_url":"https://api.github.com/users/djmitche/followers","following_url":"https://api.github.com/users/djmitche/following{/other_user}","gists_url":"https://api.github.com/users/djmitche/gists{/gist_id}","starred_url":"https://api.github.com/users/djmitche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djmitche/subscriptions","organizations_url":"https://api.github.com/users/djmitche/orgs","repos_url":"https://api.github.com/users/djmitche/repos","events_url":"https://api.github.com/users/djmitche/events{/privacy}","received_events_url":"https://api.github.com/users/djmitche/received_events","type":"User","site_admin":false},"repo":{"id":18447111,"name":"build-relengapi","full_name":"djmitche/build-relengapi","owner":{"login":"djmitche","id":28673,"avatar_url":"https://avatars.githubusercontent.com/u/28673?v=3","gravatar_id":"","url":"https://api.github.com/users/djmitche","html_url":"https://github.com/djmitche","followers_url":"https://api.github.com/users/djmitche/followers","following_url":"https://api.github.com/users/djmitche/following{/other_user}","gists_url":"https://api.github.com/users/djmitche/gists{/gist_id}","starred_url":"https://api.github.com/users/djmitche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djmitche/subscriptions","organizations_url":"https://api.github.com/users/djmitche/orgs","repos_url":"https://api.github.com/users/djmitche/repos","events_url":"https://api.github.com/users/djmitche/events{/privacy}","received_events_url":"https://api.github.com/users/djmitche/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/djmitche/build-relengapi","description":"Your Interface to Release Engineering Automation -","fork":true,"url":"https://api.github.com/repos/djmitche/build-relengapi","forks_url":"https://api.github.com/repos/djmitche/build-relengapi/forks","keys_url":"https://api.github.com/repos/djmitche/build-relengapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/djmitche/build-relengapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/djmitche/build-relengapi/teams","hooks_url":"https://api.github.com/repos/djmitche/build-relengapi/hooks","issue_events_url":"https://api.github.com/repos/djmitche/build-relengapi/issues/events{/number}","events_url":"https://api.github.com/repos/djmitche/build-relengapi/events","assignees_url":"https://api.github.com/repos/djmitche/build-relengapi/assignees{/user}","branches_url":"https://api.github.com/repos/djmitche/build-relengapi/branches{/branch}","tags_url":"https://api.github.com/repos/djmitche/build-relengapi/tags","blobs_url":"https://api.github.com/repos/djmitche/build-relengapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/djmitche/build-relengapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/djmitche/build-relengapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/djmitche/build-relengapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/djmitche/build-relengapi/statuses/{sha}","languages_url":"https://api.github.com/repos/djmitche/build-relengapi/languages","stargazers_url":"https://api.github.com/repos/djmitche/build-relengapi/stargazers","contributors_url":"https://api.github.com/repos/djmitche/build-relengapi/contributors","subscribers_url":"https://api.github.com/repos/djmitche/build-relengapi/subscribers","subscription_url":"https://api.github.com/repos/djmitche/build-relengapi/subscription","commits_url":"https://api.github.com/repos/djmitche/build-relengapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/djmitche/build-relengapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/djmitche/build-relengapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/djmitche/build-relengapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/djmitche/build-relengapi/contents/{+path}","compare_url":"https://api.github.com/repos/djmitche/build-relengapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/djmitche/build-relengapi/merges","archive_url":"https://api.github.com/repos/djmitche/build-relengapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/djmitche/build-relengapi/downloads","issues_url":"https://api.github.com/repos/djmitche/build-relengapi/issues{/number}","pulls_url":"https://api.github.com/repos/djmitche/build-relengapi/pulls{/number}","milestones_url":"https://api.github.com/repos/djmitche/build-relengapi/milestones{/number}","notifications_url":"https://api.github.com/repos/djmitche/build-relengapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/djmitche/build-relengapi/labels{/name}","releases_url":"https://api.github.com/repos/djmitche/build-relengapi/releases{/id}","created_at":"2014-04-04T17:46:01Z","updated_at":"2015-03-24T23:24:03Z","pushed_at":"2015-03-24T23:24:02Z","git_url":"git://github.com/djmitche/build-relengapi.git","ssh_url":"git@github.com:djmitche/build-relengapi.git","clone_url":"https://github.com/djmitche/build-relengapi.git","svn_url":"https://github.com/djmitche/build-relengapi","homepage":"https://api.pub.build.mozilla.org","size":2848,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"b1641c06311d01fcd3cd381d9c64bf1264ac4766","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":18413379,"name":"build-relengapi","full_name":"mozilla/build-relengapi","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/build-relengapi","description":"Your Interface to Release Engineering Automation -","fork":false,"url":"https://api.github.com/repos/mozilla/build-relengapi","forks_url":"https://api.github.com/repos/mozilla/build-relengapi/forks","keys_url":"https://api.github.com/repos/mozilla/build-relengapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/build-relengapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/build-relengapi/teams","hooks_url":"https://api.github.com/repos/mozilla/build-relengapi/hooks","issue_events_url":"https://api.github.com/repos/mozilla/build-relengapi/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/build-relengapi/events","assignees_url":"https://api.github.com/repos/mozilla/build-relengapi/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/build-relengapi/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/build-relengapi/tags","blobs_url":"https://api.github.com/repos/mozilla/build-relengapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/build-relengapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/build-relengapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/build-relengapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/build-relengapi/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/build-relengapi/languages","stargazers_url":"https://api.github.com/repos/mozilla/build-relengapi/stargazers","contributors_url":"https://api.github.com/repos/mozilla/build-relengapi/contributors","subscribers_url":"https://api.github.com/repos/mozilla/build-relengapi/subscribers","subscription_url":"https://api.github.com/repos/mozilla/build-relengapi/subscription","commits_url":"https://api.github.com/repos/mozilla/build-relengapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/build-relengapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/build-relengapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/build-relengapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/build-relengapi/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/build-relengapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/build-relengapi/merges","archive_url":"https://api.github.com/repos/mozilla/build-relengapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/build-relengapi/downloads","issues_url":"https://api.github.com/repos/mozilla/build-relengapi/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/build-relengapi/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/build-relengapi/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/build-relengapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/build-relengapi/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/build-relengapi/releases{/id}","created_at":"2014-04-03T18:20:38Z","updated_at":"2015-03-24T23:26:25Z","pushed_at":"2015-03-24T23:26:23Z","git_url":"git://github.com/mozilla/build-relengapi.git","ssh_url":"git@github.com:mozilla/build-relengapi.git","clone_url":"https://github.com/mozilla/build-relengapi.git","svn_url":"https://github.com/mozilla/build-relengapi","homepage":"https://api.pub.build.mozilla.org","size":2697,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":49,"forks":11,"open_issues":49,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186"},"html":{"href":"https://github.com/mozilla/build-relengapi/pull/186"},"issue":{"href":"https://api.github.com/repos/mozilla/build-relengapi/issues/186"},"comments":{"href":"https://api.github.com/repos/mozilla/build-relengapi/issues/186/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/build-relengapi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/build-relengapi/pulls/186/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/build-relengapi/statuses/e67c0e03250be4d5f7e422de87478bb3849800a1"}}}}