{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/comments/95222528","pull_request_review_id":15770628,"id":95222528,"diff_hunk":"@@ -605,16 +612,35 @@ public HttpResponse onSuccess(String authorizationCode) {\n         };\n     }\n     \n-    public void updateAuthorizationStrategy(OAuthSession oauth) throws IOException, GeneralSecurityException {\n+    public UsernamePasswordAuthenticationToken updateAuthorizationStrategy(Credential credential) throws IOException, GeneralSecurityException {\n     \tpopulateDefaults();\n-        OpenShiftUserInfo info = getOpenShiftUserInfo(oauth.getCredential(), transport);\n-        Set<String> allowedRoles = postSAR(oauth.getCredential(), transport);\n+        OpenShiftUserInfo info = getOpenShiftUserInfo(credential, transport);\n+        Set<String> allowedRoles = postSAR(credential, transport);\n         GrantedAuthority[] authorities = new GrantedAuthority[] {SecurityRealm.AUTHENTICATED_AUTHORITY};\n+                \n+        // we append the role suffix to the name stored into Jenkins, since a given user is able to log in at varying scope/permission\n+        // levels in openshift; however, for now, we make sure the display name for Jenkins does not include this suffix\n+        String suffix = \"\";\n+        if (allowedRoles.contains(\"admin\"))\n+            suffix = \"-admin\";\n+        else if (allowedRoles.contains(\"edit\"))\n+            suffix = \"-edit\";\n+        else if (allowedRoles.contains(\"view\"))\n+            suffix = \"view\";\n+        String matrixKey = info.getName() + suffix;\n+        \n         // logs this user in.\n         UsernamePasswordAuthenticationToken token =\n-                new UsernamePasswordAuthenticationToken(info.getName(), \"\", authorities);\n+                new UsernamePasswordAuthenticationToken(matrixKey, \"\", authorities);\n         SecurityContextHolder.getContext().setAuthentication(token);\n         \n+        User u = User.get(token.getName());","path":"src/main/java/org/openshift/jenkins/plugins/openshiftlogin/OpenShiftOAuth2SecurityRealm.java","position":125,"original_position":125,"commit_id":"48434ff05bae8f6c075bde66fb2335781fa7d830","original_commit_id":"48434ff05bae8f6c075bde66fb2335781fa7d830","user":{"login":"bparees","id":4974046,"avatar_url":"https://avatars.githubusercontent.com/u/4974046?v=3","gravatar_id":"","url":"https://api.github.com/users/bparees","html_url":"https://github.com/bparees","followers_url":"https://api.github.com/users/bparees/followers","following_url":"https://api.github.com/users/bparees/following{/other_user}","gists_url":"https://api.github.com/users/bparees/gists{/gist_id}","starred_url":"https://api.github.com/users/bparees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bparees/subscriptions","organizations_url":"https://api.github.com/users/bparees/orgs","repos_url":"https://api.github.com/users/bparees/repos","events_url":"https://api.github.com/users/bparees/events{/privacy}","received_events_url":"https://api.github.com/users/bparees/received_events","type":"User","site_admin":false},"body":"token.getName() is the name of the token, or the name of the account associated w/ the the token?  if it's the latter it's going to be a problem once we support scoped tokens and so you have multiple tokens for the same username.\r\n\r\n(and if it's the former, it seems like it would be a problem if the same token name is used within different projects)\r\n","created_at":"2017-01-09T19:02:00Z","updated_at":"2017-01-09T19:15:58Z","html_url":"https://github.com/openshift/jenkins-openshift-login-plugin/pull/7#discussion_r95222528","pull_request_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/comments/95222528"},"html":{"href":"https://github.com/openshift/jenkins-openshift-login-plugin/pull/7#discussion_r95222528"},"pull_request":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7","id":100520958,"html_url":"https://github.com/openshift/jenkins-openshift-login-plugin/pull/7","diff_url":"https://github.com/openshift/jenkins-openshift-login-plugin/pull/7.diff","patch_url":"https://github.com/openshift/jenkins-openshift-login-plugin/pull/7.patch","issue_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/issues/7","number":7,"state":"open","locked":false,"title":"access jenkins via bearer token self-sar against openshift oauth; ens…","user":{"login":"gabemontero","id":3594868,"avatar_url":"https://avatars.githubusercontent.com/u/3594868?v=3","gravatar_id":"","url":"https://api.github.com/users/gabemontero","html_url":"https://github.com/gabemontero","followers_url":"https://api.github.com/users/gabemontero/followers","following_url":"https://api.github.com/users/gabemontero/following{/other_user}","gists_url":"https://api.github.com/users/gabemontero/gists{/gist_id}","starred_url":"https://api.github.com/users/gabemontero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabemontero/subscriptions","organizations_url":"https://api.github.com/users/gabemontero/orgs","repos_url":"https://api.github.com/users/gabemontero/repos","events_url":"https://api.github.com/users/gabemontero/events{/privacy}","received_events_url":"https://api.github.com/users/gabemontero/received_events","type":"User","site_admin":false},"body":"…ure filter is active after restart\r\n\r\n@bparees FYI / PTAL","created_at":"2017-01-06T20:37:07Z","updated_at":"2017-01-09T19:15:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d8b18db4dc852031da39d9251d1beb9848149970","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7/commits","review_comments_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7/comments","review_comment_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/issues/7/comments","statuses_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/statuses/48434ff05bae8f6c075bde66fb2335781fa7d830","head":{"label":"gabemontero:bearerTokenAccess","ref":"bearerTokenAccess","sha":"48434ff05bae8f6c075bde66fb2335781fa7d830","user":{"login":"gabemontero","id":3594868,"avatar_url":"https://avatars.githubusercontent.com/u/3594868?v=3","gravatar_id":"","url":"https://api.github.com/users/gabemontero","html_url":"https://github.com/gabemontero","followers_url":"https://api.github.com/users/gabemontero/followers","following_url":"https://api.github.com/users/gabemontero/following{/other_user}","gists_url":"https://api.github.com/users/gabemontero/gists{/gist_id}","starred_url":"https://api.github.com/users/gabemontero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabemontero/subscriptions","organizations_url":"https://api.github.com/users/gabemontero/orgs","repos_url":"https://api.github.com/users/gabemontero/repos","events_url":"https://api.github.com/users/gabemontero/events{/privacy}","received_events_url":"https://api.github.com/users/gabemontero/received_events","type":"User","site_admin":false},"repo":{"id":61748932,"name":"jenkins-openshift-login-plugin","full_name":"gabemontero/jenkins-openshift-login-plugin","owner":{"login":"gabemontero","id":3594868,"avatar_url":"https://avatars.githubusercontent.com/u/3594868?v=3","gravatar_id":"","url":"https://api.github.com/users/gabemontero","html_url":"https://github.com/gabemontero","followers_url":"https://api.github.com/users/gabemontero/followers","following_url":"https://api.github.com/users/gabemontero/following{/other_user}","gists_url":"https://api.github.com/users/gabemontero/gists{/gist_id}","starred_url":"https://api.github.com/users/gabemontero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabemontero/subscriptions","organizations_url":"https://api.github.com/users/gabemontero/orgs","repos_url":"https://api.github.com/users/gabemontero/repos","events_url":"https://api.github.com/users/gabemontero/events{/privacy}","received_events_url":"https://api.github.com/users/gabemontero/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gabemontero/jenkins-openshift-login-plugin","description":"A plugin for integrating OpenShift OAuth into Jenkins","fork":true,"url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin","forks_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/forks","keys_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/teams","hooks_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/hooks","issue_events_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/events","assignees_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/tags","blobs_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/languages","stargazers_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/stargazers","contributors_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/contributors","subscribers_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/subscribers","subscription_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/subscription","commits_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/merges","archive_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/downloads","issues_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/labels{/name}","releases_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/gabemontero/jenkins-openshift-login-plugin/deployments","created_at":"2016-06-22T20:21:35Z","updated_at":"2016-10-18T20:30:52Z","pushed_at":"2017-01-07T00:45:48Z","git_url":"git://github.com/gabemontero/jenkins-openshift-login-plugin.git","ssh_url":"git@github.com:gabemontero/jenkins-openshift-login-plugin.git","clone_url":"https://github.com/gabemontero/jenkins-openshift-login-plugin.git","svn_url":"https://github.com/gabemontero/jenkins-openshift-login-plugin","homepage":null,"size":135,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"openshift:master","ref":"master","sha":"f8d18f0920163331a13d709b270793d68f1f4855","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":61512183,"name":"jenkins-openshift-login-plugin","full_name":"openshift/jenkins-openshift-login-plugin","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/jenkins-openshift-login-plugin","description":"A plugin for integrating OpenShift OAuth into Jenkins","fork":false,"url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin","forks_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/forks","keys_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/teams","hooks_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/hooks","issue_events_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/events","assignees_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/tags","blobs_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/languages","stargazers_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/stargazers","contributors_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/contributors","subscribers_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/subscribers","subscription_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/subscription","commits_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/merges","archive_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/downloads","issues_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/labels{/name}","releases_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/deployments","created_at":"2016-06-20T02:45:29Z","updated_at":"2017-01-06T07:05:04Z","pushed_at":"2017-01-07T00:45:49Z","git_url":"git://github.com/openshift/jenkins-openshift-login-plugin.git","ssh_url":"git@github.com:openshift/jenkins-openshift-login-plugin.git","clone_url":"https://github.com/openshift/jenkins-openshift-login-plugin.git","svn_url":"https://github.com/openshift/jenkins-openshift-login-plugin","homepage":null,"size":130,"stargazers_count":3,"watchers_count":3,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":2,"forks":6,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7"},"html":{"href":"https://github.com/openshift/jenkins-openshift-login-plugin/pull/7"},"issue":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/issues/7"},"comments":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/jenkins-openshift-login-plugin/statuses/48434ff05bae8f6c075bde66fb2335781fa7d830"}}}}
{"actor":{"display_login":"bparees"}}