Bean validation is executed before @PreAuthorize
See original GitHub issue@RestController
public class SomeController {
@PreAuthorize("@security.isAuthenticated()")
@PostMapping("/todo")
public void add(@Valid @RequestBody dto: SomeDto) {
}
}
Method isAuthenticated
should be executed before deserialization and validation of action parameters.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to make @PreAuthorize having higher precedence than ...
The @PreAuthorize is only invoked when the method is executed. However the @Valid is processed in preparing the execution of the method, which ......
Read more >Spring Method Security with PreAuthorize - Okta Developer
This tutorial will explore two ways to configure authentication and authorization in Spring Boot using Spring Security.
Read more >Spring Security: Delegating authorization checks to bean ...
This post shows how authorization checks can be delegated to bean methods with Spring Security. This can be a very useful feature which...
Read more >Spring Security @PreAuthorize Annotation Example
In this Spring Security tutorial, you will learn how to use the @PreAuthorize annotation to secure method invocation.
Read more >Deny Access on Missing @PreAuthorize to Spring Controller ...
When running the example, we can sign in with user/password. Then, we access the /hello endpoint. We can also sign in with guest/guest....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think everybody agree with the simply rule “Security First” . Sorry but for me this is a big issue why do we want to run the validation and return validation error if somebody has not event permission to this endpoint? Also the explanation for me its not professional, its sound like “we don’t care with the basic security rules the design is more important than the security”.
Now how we can be confident by using spring security once we know that we can run some other methods before we actually authorise user. The simple question after all is: what else other than validation is running before security check ?
@wilkinsona sorry for that I just want to express that I really dislike this behaviour. I updated my comment so now I hope is fine. I will definitely raise this ticket with spring security team and chat with them on Gitter.