My application acts, among other things, as OAuth2 resource server and OAuth2 authorization server. I have AuthenticationManager configured with a chain of AuthenticationProviders (that is, a ProviderManager):
Providers are tried one after other, until a suitable one is found.Code:<security:authentication-manager alias="authenticationManager"> <!-- Register an authentication provider which can validate SFSESSION cookies --> <security:authentication-provider ref="sfAuthProvider" /> <!--Basic authentication provider--> <security:authentication-provider ref="sfBasicAuthProvider"/> </security:authentication-manager>
I have created and added a custom OAuth2 AuthenticationProvider (a wrapper around OAuth2AuthenticationManager):
This contradicts with the approach described in Spring OAuth2 docs, which suggest to create an instance of OAuth2AuthenticationProcessingFilter with <oauth:resource-server element. OAuth2AuthenticationProcessingFilter is tied directly to OAuth2AuthenticationManager, that is, it does not allow any oauth-specific AuthenticationProviders.Code:<security:authentication-manager alias="authenticationManager"> <!-- Register an authentication provider which can validate SFSESSION cookies --> <security:authentication-provider ref="sfAuthProvider" /> <!--Basic authentication provider--> <security:authentication-provider ref="sfBasicAuthProvider"/> <!--OAuth2 provider--> <security:authentication-provider ref="sfOAuth2Provider"/> </security:authentication-manager>
Am I doing something wrong? Is there a better practice to incorporate Spring OAuth2 into existing Security infrastructure?


Reply With Quote