{"action":"created","comment":{"url":"https://api.github.com/repos/influxdata/chronograf/pulls/comments/145715377","pull_request_review_id":70554541,"id":145715377,"diff_hunk":"@@ -45,3 +45,84 @@ func AuthorizedToken(auth oauth2.Authenticator, logger chronograf.Logger, next h\n \t\treturn\n \t})\n }\n+\n+// AuthorizedUser extracts the user name and provider from context. If the user and provider can be found on the\n+// context, we look up the user by their name and provider. If the user is found, we verify that the user has at\n+// at least the role supplied.\n+func AuthorizedUser(store chronograf.UsersStore, useAuth bool, role string, logger chronograf.Logger, next http.HandlerFunc) http.HandlerFunc {\n+\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n+\t\tif !useAuth {\n+\t\t\tnext(w, r)\n+\t\t\treturn\n+\t\t}\n+\n+\t\tlog := logger.\n+\t\t\tWithField(\"component\", \"role_auth\").\n+\t\t\tWithField(\"remote_addr\", r.RemoteAddr).\n+\t\t\tWithField(\"method\", r.Method).\n+\t\t\tWithField(\"url\", r.URL)\n+\n+\t\tctx := r.Context()\n+\n+\t\tusername, err := getUsername(ctx)\n+\t\tif err != nil {\n+\t\t\tlog.Error(\"Failed to retrieve username from context\")\n+\t\t\tError(w, http.StatusUnauthorized, \"User is not authorized\", logger)\n+\t\t\treturn\n+\t\t}\n+\t\tprovider, err := getProvider(ctx)\n+\t\tif err != nil {\n+\t\t\tlog.Error(\"Failed to retrieve provider from context\")","path":"server/auth.go","position":31,"original_position":31,"commit_id":"34414df01698471a45f6bb07f7434f3bdf47ec3f","original_commit_id":"34414df01698471a45f6bb07f7434f3bdf47ec3f","user":{"login":"jaredscheib","id":6403018,"avatar_url":"https://avatars1.githubusercontent.com/u/6403018?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredscheib","html_url":"https://github.com/jaredscheib","followers_url":"https://api.github.com/users/jaredscheib/followers","following_url":"https://api.github.com/users/jaredscheib/following{/other_user}","gists_url":"https://api.github.com/users/jaredscheib/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredscheib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredscheib/subscriptions","organizations_url":"https://api.github.com/users/jaredscheib/orgs","repos_url":"https://api.github.com/users/jaredscheib/repos","events_url":"https://api.github.com/users/jaredscheib/events{/privacy}","received_events_url":"https://api.github.com/users/jaredscheib/received_events","type":"User","site_admin":false},"body":"might be useful to specify around here that this is during an API request","created_at":"2017-10-19T14:23:46Z","updated_at":"2017-10-19T14:59:49Z","html_url":"https://github.com/influxdata/chronograf/pull/2132#discussion_r145715377","pull_request_url":"https://api.github.com/repos/influxdata/chronograf/pulls/2132","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/influxdata/chronograf/pulls/comments/145715377"},"html":{"href":"https://github.com/influxdata/chronograf/pull/2132#discussion_r145715377"},"pull_request":{"href":"https://api.github.com/repos/influxdata/chronograf/pulls/2132"}}},"pull_request":{"url":"https://api.github.com/repos/influxdata/chronograf/pulls/2132","id":147381735,"html_url":"https://github.com/influxdata/chronograf/pull/2132","diff_url":"https://github.com/influxdata/chronograf/pull/2132.diff","patch_url":"https://github.com/influxdata/chronograf/pull/2132.patch","issue_url":"https://api.github.com/repos/influxdata/chronograf/issues/2132","number":2132,"state":"open","locked":false,"title":"Role based authorization","user":{"login":"desa","id":1477539,"avatar_url":"https://avatars1.githubusercontent.com/u/1477539?v=4","gravatar_id":"","url":"https://api.github.com/users/desa","html_url":"https://github.com/desa","followers_url":"https://api.github.com/users/desa/followers","following_url":"https://api.github.com/users/desa/following{/other_user}","gists_url":"https://api.github.com/users/desa/gists{/gist_id}","starred_url":"https://api.github.com/users/desa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/desa/subscriptions","organizations_url":"https://api.github.com/users/desa/orgs","repos_url":"https://api.github.com/users/desa/repos","events_url":"https://api.github.com/users/desa/events{/privacy}","received_events_url":"https://api.github.com/users/desa/received_events","type":"User","site_admin":false},"body":"  - [ ] Rebased/mergable\r\n  - [ ] Tests pass\r\n\r\nConnect #2100\r\nConnect #1915\r\nConnect #1914 \r\n\r\n\r\n","created_at":"2017-10-18T18:52:02Z","updated_at":"2017-10-19T14:59:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cbffc4f37075f3d527577592b70d86122b8e2d90","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/influxdata/chronograf/pulls/2132/commits","review_comments_url":"https://api.github.com/repos/influxdata/chronograf/pulls/2132/comments","review_comment_url":"https://api.github.com/repos/influxdata/chronograf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdata/chronograf/issues/2132/comments","statuses_url":"https://api.github.com/repos/influxdata/chronograf/statuses/34414df01698471a45f6bb07f7434f3bdf47ec3f","head":{"label":"influxdata:multitenancy_authorize_role","ref":"multitenancy_authorize_role","sha":"34414df01698471a45f6bb07f7434f3bdf47ec3f","user":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":66506962,"name":"chronograf","full_name":"influxdata/chronograf","owner":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdata/chronograf","description":"Open source monitoring and visualization UI for the TICK stack","fork":false,"url":"https://api.github.com/repos/influxdata/chronograf","forks_url":"https://api.github.com/repos/influxdata/chronograf/forks","keys_url":"https://api.github.com/repos/influxdata/chronograf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/chronograf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/chronograf/teams","hooks_url":"https://api.github.com/repos/influxdata/chronograf/hooks","issue_events_url":"https://api.github.com/repos/influxdata/chronograf/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/chronograf/events","assignees_url":"https://api.github.com/repos/influxdata/chronograf/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/chronograf/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/chronograf/tags","blobs_url":"https://api.github.com/repos/influxdata/chronograf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/chronograf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/chronograf/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/chronograf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/chronograf/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/chronograf/languages","stargazers_url":"https://api.github.com/repos/influxdata/chronograf/stargazers","contributors_url":"https://api.github.com/repos/influxdata/chronograf/contributors","subscribers_url":"https://api.github.com/repos/influxdata/chronograf/subscribers","subscription_url":"https://api.github.com/repos/influxdata/chronograf/subscription","commits_url":"https://api.github.com/repos/influxdata/chronograf/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/chronograf/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/chronograf/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/chronograf/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/chronograf/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/chronograf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/chronograf/merges","archive_url":"https://api.github.com/repos/influxdata/chronograf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/chronograf/downloads","issues_url":"https://api.github.com/repos/influxdata/chronograf/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/chronograf/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/chronograf/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/chronograf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/chronograf/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/chronograf/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/chronograf/deployments","created_at":"2016-08-24T23:28:56Z","updated_at":"2017-10-19T10:58:24Z","pushed_at":"2017-10-19T03:33:43Z","git_url":"git://github.com/influxdata/chronograf.git","ssh_url":"git@github.com:influxdata/chronograf.git","clone_url":"https://github.com/influxdata/chronograf.git","svn_url":"https://github.com/influxdata/chronograf","homepage":"https://www.influxdata.com/time-series-platform/chronograf/","size":42977,"stargazers_count":403,"watchers_count":403,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"open_issues_count":317,"forks":86,"open_issues":317,"watchers":403,"default_branch":"master"}},"base":{"label":"influxdata:multitenancy","ref":"multitenancy","sha":"b85ba866ab1192e020570d197195c0b94b68012a","user":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":66506962,"name":"chronograf","full_name":"influxdata/chronograf","owner":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdata/chronograf","description":"Open source monitoring and visualization UI for the TICK stack","fork":false,"url":"https://api.github.com/repos/influxdata/chronograf","forks_url":"https://api.github.com/repos/influxdata/chronograf/forks","keys_url":"https://api.github.com/repos/influxdata/chronograf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/chronograf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/chronograf/teams","hooks_url":"https://api.github.com/repos/influxdata/chronograf/hooks","issue_events_url":"https://api.github.com/repos/influxdata/chronograf/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/chronograf/events","assignees_url":"https://api.github.com/repos/influxdata/chronograf/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/chronograf/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/chronograf/tags","blobs_url":"https://api.github.com/repos/influxdata/chronograf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/chronograf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/chronograf/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/chronograf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/chronograf/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/chronograf/languages","stargazers_url":"https://api.github.com/repos/influxdata/chronograf/stargazers","contributors_url":"https://api.github.com/repos/influxdata/chronograf/contributors","subscribers_url":"https://api.github.com/repos/influxdata/chronograf/subscribers","subscription_url":"https://api.github.com/repos/influxdata/chronograf/subscription","commits_url":"https://api.github.com/repos/influxdata/chronograf/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/chronograf/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/chronograf/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/chronograf/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/chronograf/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/chronograf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/chronograf/merges","archive_url":"https://api.github.com/repos/influxdata/chronograf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/chronograf/downloads","issues_url":"https://api.github.com/repos/influxdata/chronograf/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/chronograf/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/chronograf/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/chronograf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/chronograf/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/chronograf/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/chronograf/deployments","created_at":"2016-08-24T23:28:56Z","updated_at":"2017-10-19T10:58:24Z","pushed_at":"2017-10-19T03:33:43Z","git_url":"git://github.com/influxdata/chronograf.git","ssh_url":"git@github.com:influxdata/chronograf.git","clone_url":"https://github.com/influxdata/chronograf.git","svn_url":"https://github.com/influxdata/chronograf","homepage":"https://www.influxdata.com/time-series-platform/chronograf/","size":42977,"stargazers_count":403,"watchers_count":403,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"open_issues_count":317,"forks":86,"open_issues":317,"watchers":403,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdata/chronograf/pulls/2132"},"html":{"href":"https://github.com/influxdata/chronograf/pull/2132"},"issue":{"href":"https://api.github.com/repos/influxdata/chronograf/issues/2132"},"comments":{"href":"https://api.github.com/repos/influxdata/chronograf/issues/2132/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdata/chronograf/pulls/2132/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdata/chronograf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdata/chronograf/pulls/2132/commits"},"statuses":{"href":"https://api.github.com/repos/influxdata/chronograf/statuses/34414df01698471a45f6bb07f7434f3bdf47ec3f"}},"author_association":"NONE"}}
{"actor":{"display_login":"jaredscheib"}}