-
Notifications
You must be signed in to change notification settings - Fork 6k
Add @AuthorizeRequestMapping annotation #16250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
At the risk of making the issue too noisy with ideas, something we might consider is annotations that do not allow SpEL. For example: @HasRole("ADMIN")
@HasScope("message:read")
@AuthorizeRequest(authorizationManagerClass=MyAuthorizationManager.class) This allows not needing to consider method parameters. It also (wisely, IMO) drives applications towards using beans instead of expressions. The authorization manager implementations would be of type One possibly risky thing that I'm considering is that some of these could double as method annotations in other places. That is, when |
The concern I have with adding
Would it make sense to scan all the |
My thoughts went in the same direction as @jgrandja. Could the existing annotation be made use of? In effect enhancing the evaluation of the annotation when used on a web controller to take place earlier when feasible (i.e. no use of method parameters)? It wouldn't require applications to roll out a new annotation for what is an implementation detail, and would just work on existing setups. The name is also much too long for a highly visible annotation. We shortened As an alternative, if this does not work out, perhaps something more broadly useful that has additional user visible value (vs dealing with an implementation detail) along the lines of @jzheaux's comment. |
I do not think that we can reuse an existing annotation (e.g. The semantics of As for the name I think that we can iterate on that. I think that I like the idea of experimenting with Josh's suggestion. The concern around it being used on method security is not necessarily a bad thing because these annotations would behave the same (authority/role/scope) based security doesn't care about the object being secured. We could allow both method security and the web based security to act upon the same annotation in the same way. |
@evgeniycheban I think that we need to start with gh-16249 since |
@rwinch sure, can you assign it to me? |
Combined with gh-16249 we could add an annotation (e.g.
@AuthorizeRequestMapping
) that allows adding authorization rules to Spring Controllers but happens at the same time asauthorizeHttpRequests()
(to reduce the attack surface) rather than late like method security.The need for a new annotation is due to the fact that
@PreAuthorize
allows access to method parameters, but we will not have access to those parameters in a web based authorization model.We'd need the ability to scan for all annotated controllers and create a mapping of the RequestMapping to authorization rules.
A few examples:
The following adds an authorization rule that only admin can access the routes of
/admin/users/{id}
and/admin/users/
.We also need the ability to take into account all of the information that a Spring Controller would take into account (e.g. HTTP Method, Content negotiation, etc).
cc @rstoyanchev
The text was updated successfully, but these errors were encountered: