Spring Security with Hibernate using authentication provider with @preAuthorize annotation
We are using the sample horrormovie
application to demonstrate Spring Security with Hibernate using custom authentication provider and @preAuthorize
annotation.
In this recipe we will create our own custom authentication provider and implement the interface authentication provider. We will apply the annotation on the controller
method instead of the hibernate
method.
Getting ready
Create a new class which implements the
AuthenticationProvider
interface and add the Bean definition to theapplication-security.xml
fileEdit the
application-security.xml
fileUse the
@preAuthorize
annotation in controller
How to do it...
The following steps are used to implement Spring Security by using the AuthenticationProvider
interface:
Edit the
application-security.xml
file with data source details and Bean information.<global-method-security pre-post-annotations="enabled" /> <http auto-config="false" use-expressions...