question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
ghostcommented, Dec 14, 2018

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 ?

3reactions
ghostcommented, Dec 14, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found