Currently, I am creating one login module for the project. In this module authentication and authorization must be required.
I am implementing the UserDetailsService interface in service class but I am not using this interface.
UserDetailsService is the interface of Spring Security.
Is there any way to achieve authentication and authorization without implementing the UserDetailsService interface in Spring with Hibernate?
I am currently working on java spring-mvc and Hibernate.
Yes
Write a class by extending AbstractUserDetailsAuthenticationProvider
and overide retrieveUser
method there you can write your logic for authentication and authorization
@Override
protected UserDetails retrieveUser(String username,final UsernamePasswordAuthenticationToken authentication) throws AuthenticationException
And inthe Spring security xml
<security:authentication-manager id="restAuthManager">
<security:authentication-provider
ref="restAuthProvider">
</security:authentication-provider>
</security:authentication-manager>
<beans:bean id="restAuthProvider" class="com.MyExtendedClass"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.