Open m11y opened 8 years ago
I had the same issue. as a workaround, I defined my TokenServices as primary ones:
@Bean @Primary public ResourceServerTokenServices getResourceServerTokenServices() { return myTokenServices; }
Another way to do it is to inject the AuthorizationServerEndpointsConfiguration
bean:
@Autowired
private AuthorizationServerEndpointsConfiguration endpoints;
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
resources.tokenServices(endpoints.getEndpointsConfigurer().getResourceServerTokenServices());
}
or use it to expose the services bean
@Bean
public ResourceServerTokenServices resourceServerTokenServices(AuthorizationServerEndpointsConfiguration endpoints) {
return endpoints.getEndpointsConfigurer().getResourceServerTokenServices()
}
@dsyer is there a reason that resolveTokenServices()
doesn't do this itself?
It will get the token store from the endpoint config, but not the token services.
I dig into the code, and find code in
ResourceServerConfiguration
:the code above limits that only one instance of
ResourceServerTokenServices
exists.And code in
AuthorizationServerEndpointsConfiguration
:always register
defaultAuthorizationServerTokenServices
which implmentsResourceServerTokenServices
.when implements custom
tokenServices
, exceptions was thrown.