Reputation: 5655
Does Spring security
having any implementation to restrict user based on their username
?
I know this we can do it through filters using some if
checks, though I am curious to know, does Spring Security having any such kinda of implementations?
Upvotes: 0
Views: 1259
Reputation: 16614
Sure.
For example, an annotation that only allows the method to be run by user "admin":
@PreAuthorize("authentication.name == 'admin'")
public void doAdminStuff();
You can reference a Spring bean with @
:
@PreAuthorize("@myService.hasPermission(authentication.name)")
public void doSomeStuff();
Upvotes: 1