{"action":"created","comment":{"url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/comments/177230173","pull_request_review_id":107067834,"id":177230173,"diff_hunk":"@@ -0,0 +1,31 @@\n+/*\n+ * Copyright 2002-2018 the original author or authors.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.springframework.security.access.expression;\n+\n+import org.springframework.security.core.Authentication;\n+\n+import java.util.function.Function;\n+\n+/**\n+ * A contract for indicating work to be done that relies on the present\n+ * {@link Authentication} object\n+ *\n+ * @author Josh Cummings\n+ * @since 5.1\n+ */\n+public interface AuthenticationResolver {\n+\t<OUT> OUT doWithAuthentication(Function<Authentication, OUT> todo);","path":"oauth2/oauth2-resource-server/src/main/java/org/springframework/security/access/expression/AuthenticationResolver.java","position":null,"original_position":30,"commit_id":"f98d8aba551e0235c69c2cb532e384490a12ce58","original_commit_id":"f884fea3cbd9def6364258ec2d7e0aa89d47759a","user":{"login":"jgrandja","id":10884212,"avatar_url":"https://avatars1.githubusercontent.com/u/10884212?v=4","gravatar_id":"","url":"https://api.github.com/users/jgrandja","html_url":"https://github.com/jgrandja","followers_url":"https://api.github.com/users/jgrandja/followers","following_url":"https://api.github.com/users/jgrandja/following{/other_user}","gists_url":"https://api.github.com/users/jgrandja/gists{/gist_id}","starred_url":"https://api.github.com/users/jgrandja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgrandja/subscriptions","organizations_url":"https://api.github.com/users/jgrandja/orgs","repos_url":"https://api.github.com/users/jgrandja/repos","events_url":"https://api.github.com/users/jgrandja/events{/privacy}","received_events_url":"https://api.github.com/users/jgrandja/received_events","type":"User","site_admin":false},"body":"I also like:\r\n\r\n```\r\npublic class OAuth2Expressions {\r\n    public boolean hasScope(Authentication authentication, String scope) {\r\n\r\n    }\r\n    ...\r\n}\r\n```\r\n\r\nBut I don't feel `Authentication` is required in each method. We could define an interface:\r\n\r\n```\r\npublic interface OAuth2Expressions {\r\n    public boolean hasScope(String scope);\r\n    \r\n    public boolean hasAnyScope(String... scope);\r\n    ...\r\n}\r\n```\r\n\r\nAnd the implementations can be constructed with an `Authentication` via it's constructor. The `Authentication` would first be resolved in the Servlet or Reactive environment and than the implementation of `OAuth2Expressions` would be constructed with the resolved `Authentication`.","created_at":"2018-03-26T20:50:28Z","updated_at":"2018-03-26T20:50:28Z","html_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server/pull/7#discussion_r177230173","pull_request_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/comments/177230173"},"html":{"href":"https://github.com/jzheaux/spring-security-oauth2-resource-server/pull/7#discussion_r177230173"},"pull_request":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7"}},"in_reply_to_id":176074844},"pull_request":{"url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7","id":176347825,"html_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server/pull/7","diff_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server/pull/7.diff","patch_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server/pull/7.patch","issue_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/7","number":7,"state":"open","locked":false,"title":"Initial OAuth2 SpEL Expression Support","user":{"login":"jzheaux","id":3627351,"avatar_url":"https://avatars0.githubusercontent.com/u/3627351?v=4","gravatar_id":"","url":"https://api.github.com/users/jzheaux","html_url":"https://github.com/jzheaux","followers_url":"https://api.github.com/users/jzheaux/followers","following_url":"https://api.github.com/users/jzheaux/following{/other_user}","gists_url":"https://api.github.com/users/jzheaux/gists{/gist_id}","starred_url":"https://api.github.com/users/jzheaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzheaux/subscriptions","organizations_url":"https://api.github.com/users/jzheaux/orgs","repos_url":"https://api.github.com/users/jzheaux/repos","events_url":"https://api.github.com/users/jzheaux/events{/privacy}","received_events_url":"https://api.github.com/users/jzheaux/received_events","type":"User","site_admin":false},"body":"Support for beans that are dependent on the Authentication object\r\nin order to perform their operations. Useful in making these beans\r\nreferenceable in SpEL expressions.\r\n\r\nFixes: spring-projects/spring-security#5132","created_at":"2018-03-20T23:13:49Z","updated_at":"2018-03-26T20:50:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e18a6e15484988819af95e80341a482d8d089025","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7/commits","review_comments_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7/comments","review_comment_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/7/comments","statuses_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/statuses/f98d8aba551e0235c69c2cb532e384490a12ce58","head":{"label":"jzheaux:gh-5132-oauth2-expression-support","ref":"gh-5132-oauth2-expression-support","sha":"f98d8aba551e0235c69c2cb532e384490a12ce58","user":{"login":"jzheaux","id":3627351,"avatar_url":"https://avatars0.githubusercontent.com/u/3627351?v=4","gravatar_id":"","url":"https://api.github.com/users/jzheaux","html_url":"https://github.com/jzheaux","followers_url":"https://api.github.com/users/jzheaux/followers","following_url":"https://api.github.com/users/jzheaux/following{/other_user}","gists_url":"https://api.github.com/users/jzheaux/gists{/gist_id}","starred_url":"https://api.github.com/users/jzheaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzheaux/subscriptions","organizations_url":"https://api.github.com/users/jzheaux/orgs","repos_url":"https://api.github.com/users/jzheaux/repos","events_url":"https://api.github.com/users/jzheaux/events{/privacy}","received_events_url":"https://api.github.com/users/jzheaux/received_events","type":"User","site_admin":false},"repo":{"id":124299025,"name":"spring-security-oauth2-resource-server","full_name":"jzheaux/spring-security-oauth2-resource-server","owner":{"login":"jzheaux","id":3627351,"avatar_url":"https://avatars0.githubusercontent.com/u/3627351?v=4","gravatar_id":"","url":"https://api.github.com/users/jzheaux","html_url":"https://github.com/jzheaux","followers_url":"https://api.github.com/users/jzheaux/followers","following_url":"https://api.github.com/users/jzheaux/following{/other_user}","gists_url":"https://api.github.com/users/jzheaux/gists{/gist_id}","starred_url":"https://api.github.com/users/jzheaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzheaux/subscriptions","organizations_url":"https://api.github.com/users/jzheaux/orgs","repos_url":"https://api.github.com/users/jzheaux/repos","events_url":"https://api.github.com/users/jzheaux/events{/privacy}","received_events_url":"https://api.github.com/users/jzheaux/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server","description":"Spring Security OAuth2 Resource Server","fork":false,"url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server","forks_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/forks","keys_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/teams","hooks_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/hooks","issue_events_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/events{/number}","events_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/events","assignees_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/assignees{/user}","branches_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/branches{/branch}","tags_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/tags","blobs_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/statuses/{sha}","languages_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/languages","stargazers_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/stargazers","contributors_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/contributors","subscribers_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/subscribers","subscription_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/subscription","commits_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/contents/{+path}","compare_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/merges","archive_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/downloads","issues_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues{/number}","pulls_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls{/number}","milestones_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/milestones{/number}","notifications_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/labels{/name}","releases_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/releases{/id}","deployments_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/deployments","created_at":"2018-03-07T21:53:26Z","updated_at":"2018-03-26T20:41:26Z","pushed_at":"2018-03-26T20:41:24Z","git_url":"git://github.com/jzheaux/spring-security-oauth2-resource-server.git","ssh_url":"git@github.com:jzheaux/spring-security-oauth2-resource-server.git","clone_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server.git","svn_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server","homepage":null,"size":208,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"jzheaux:master","ref":"master","sha":"54dbcc26d0647644690daf12420070a46ebc32b0","user":{"login":"jzheaux","id":3627351,"avatar_url":"https://avatars0.githubusercontent.com/u/3627351?v=4","gravatar_id":"","url":"https://api.github.com/users/jzheaux","html_url":"https://github.com/jzheaux","followers_url":"https://api.github.com/users/jzheaux/followers","following_url":"https://api.github.com/users/jzheaux/following{/other_user}","gists_url":"https://api.github.com/users/jzheaux/gists{/gist_id}","starred_url":"https://api.github.com/users/jzheaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzheaux/subscriptions","organizations_url":"https://api.github.com/users/jzheaux/orgs","repos_url":"https://api.github.com/users/jzheaux/repos","events_url":"https://api.github.com/users/jzheaux/events{/privacy}","received_events_url":"https://api.github.com/users/jzheaux/received_events","type":"User","site_admin":false},"repo":{"id":124299025,"name":"spring-security-oauth2-resource-server","full_name":"jzheaux/spring-security-oauth2-resource-server","owner":{"login":"jzheaux","id":3627351,"avatar_url":"https://avatars0.githubusercontent.com/u/3627351?v=4","gravatar_id":"","url":"https://api.github.com/users/jzheaux","html_url":"https://github.com/jzheaux","followers_url":"https://api.github.com/users/jzheaux/followers","following_url":"https://api.github.com/users/jzheaux/following{/other_user}","gists_url":"https://api.github.com/users/jzheaux/gists{/gist_id}","starred_url":"https://api.github.com/users/jzheaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzheaux/subscriptions","organizations_url":"https://api.github.com/users/jzheaux/orgs","repos_url":"https://api.github.com/users/jzheaux/repos","events_url":"https://api.github.com/users/jzheaux/events{/privacy}","received_events_url":"https://api.github.com/users/jzheaux/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server","description":"Spring Security OAuth2 Resource Server","fork":false,"url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server","forks_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/forks","keys_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/teams","hooks_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/hooks","issue_events_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/events{/number}","events_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/events","assignees_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/assignees{/user}","branches_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/branches{/branch}","tags_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/tags","blobs_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/statuses/{sha}","languages_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/languages","stargazers_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/stargazers","contributors_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/contributors","subscribers_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/subscribers","subscription_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/subscription","commits_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/contents/{+path}","compare_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/merges","archive_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/downloads","issues_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues{/number}","pulls_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls{/number}","milestones_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/milestones{/number}","notifications_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/labels{/name}","releases_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/releases{/id}","deployments_url":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/deployments","created_at":"2018-03-07T21:53:26Z","updated_at":"2018-03-26T20:41:26Z","pushed_at":"2018-03-26T20:41:24Z","git_url":"git://github.com/jzheaux/spring-security-oauth2-resource-server.git","ssh_url":"git@github.com:jzheaux/spring-security-oauth2-resource-server.git","clone_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server.git","svn_url":"https://github.com/jzheaux/spring-security-oauth2-resource-server","homepage":null,"size":208,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7"},"html":{"href":"https://github.com/jzheaux/spring-security-oauth2-resource-server/pull/7"},"issue":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/7"},"comments":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/jzheaux/spring-security-oauth2-resource-server/statuses/f98d8aba551e0235c69c2cb532e384490a12ce58"}},"author_association":"OWNER"}}
{"actor":{"display_login":"jgrandja"}}