Support hasScope in Method Security#18151
Conversation
9d14e8b to
4157ade
Compare
|
Hi, @ngocnhan-tran1996. We want to be careful about adding to the expression root, especially now that it has implications for public interface OAuth2AuthorizationManagerFactory<T> {
default AuthorizationManager<T> hasScope(String scope) {
return OAuth2AuthorizationManagers.hasScope(scope);
}
// ...
}And a default implementation: @Bean
OAuth2AuthorizationManagerFactory<Object> oauth2() {
return new DefaultOAuth2AuthorizationManagerFactory();
}That takes an @Bean
OAuth2AuthorizationManagerFactory<Object> oauth2(AuthorizationManagerFactory<Object> mfa) {
return new OAuth2AuthorizationManagerFactory(mfa);
}And then do: @PreAuthorize("@oauth2.hasScope('message:read')")I like this pattern since it allows for other modules to add their own expressions as well, without needing to change or extend |
e6b1d19 to
ffc9adf
Compare
|
I’ve made the requested changes. Let me know if anything else is needed. |
jzheaux
left a comment
There was a problem hiding this comment.
Thanks, @ngocnhan-tran1996! I've left some feedback inline.
...ngframework/security/oauth2/core/authorization/DefaultOAuth2AuthorizationManagerFactory.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/oauth2/core/authorization/OAuth2AuthorizationManagerFactory.java
Outdated
Show resolved
Hide resolved
...ngframework/security/oauth2/core/authorization/DefaultOAuth2AuthorizationManagerFactory.java
Show resolved
Hide resolved
Closes spring-projectsgh-18013 Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
Issue spring-projectsgh-18013 Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
|
Thanks for the PR, @ngocnhan-tran1996! This is now merged into |
Closes: gh-18013