The best option is to create a custom pre-authentication filter by extending AbstractPreAuthenticatedProcessingFilter.
You can extract the token from the request and return it to the getPreAuthenticatedCredentials () method.
You can define your own AuthenticationUserDetailsService and pass it to PreAuthenticatedAuthenticationProvider, here you can get the granted authority and return it to the UserDetails Object
<bean id="preAuthAuthenticationProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider"> <property name="preAuthenticatedUserDetailsService"> <bean id="myUserDetailsService" class="MyUserDetailsService"> </bean> </property> </bean>
If you provided auth without starting with the default ROLE prefix, you can define your own prefix
<bean id="myPermissionRoleVoter" class="org.springframework.security.access.vote.RoleVoter"> <property name="rolePrefix" value="myprefix"/> </bean>
source share