I'm investigating how the client id and client secret can be authenticated with LDAP.
Note: this Kotlin code...
@Configuration
@EnableAuthorizationServer
class OAuth2AuthorizationServerConfig() : AuthorizationServerConfigurerAdapter() {
I'm relatively new to Spring and it seems that this is not something I should be trying to? However, it seems like a useful option. Why? Because it allows me to delegate the client secret management to an LDAP directory and, effectively, allow my ops team to change the secret (in some managed way of coure). With this my application does not need to know the secret. This seems pretty neat?
The oauth end point is basic auth - this seems to be what Spring gives me with the @EnableAuthorizationServer
annotation. Requests to the http://somehost/oauth/token
specify grant_type
:client_credentials
.
I created code to get an arbitrary token (sandbox)...and what I'd like is to just specify the client and scopes that apply to that client and not specify the secret...
@Throws(Exception::class)
override fun configure(
clients: ClientDetailsServiceConfigurer
) {
// Inlining will create a store per credential entry
val serviceBuilder = clients.inMemory()
serviceBuilder.withClient("user").secret("test").scopes("XXX")
}
I have tried loads of different ideas to add an LDAP Authentication Provider
to the managed set of providers in the ProviderManager
and thus far have failed. If I debug into the authenticate
method at run time I only always have the AnonymousAuthenticationProvider
and DaoAuthenticationProvider
The following probably shows my inexperience but here's one example and please read past the probable crazyness - just trying to see if I can inject an LDAPAuthenticationProvider
...
@Autowired
lateinit var providerMan: AuthenticationManager
@Throws(Exception::class)
override fun configure(endpoints: AuthorizationServerEndpointsConfigurer) {
(providerMan as ProviderManager).providers.add(0,
LdapAuthenticationProvider(
PasswordComparisonAuthenticator(PasswordPolicyAwareContextSource("ldap://something"))
)
)
}
Question is therefore fairly simple...
Is there a way to add an LdapAuthenticationProvider
such that I can use LDAP to authenticate the client id and client secret?