Class LdapAuthenticationProvider<T>
- Type Parameters:
T- Request Context Type
- All Implemented Interfaces:
AuthenticationProvider<T>,Closeable,AutoCloseable
LdapConfiguration. One provider will be created for each configuration.- Since:
- 1.0
- Author:
- James Kleeh
-
Constructor Summary
ConstructorsConstructorDescriptionLdapAuthenticationProvider(LdapConfiguration configuration, LdapSearchService ldapSearchService, ContextBuilder contextBuilder, ContextAuthenticationMapper contextAuthenticationMapper, LdapGroupProcessor ldapGroupProcessor, ExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<AuthenticationResponse> authenticate(T requestContext, AuthenticationRequest<?, ?> authenticationRequest) Authenticates a user with the given request.voidclose()protected AuthenticationResponserejectUnknownUser(T requestContext, AuthenticationRequest<?, ?> authenticationRequest) Rejects an authentication request whose username did not match any directory entry.
-
Constructor Details
-
LdapAuthenticationProvider
public LdapAuthenticationProvider(LdapConfiguration configuration, LdapSearchService ldapSearchService, ContextBuilder contextBuilder, ContextAuthenticationMapper contextAuthenticationMapper, LdapGroupProcessor ldapGroupProcessor, @Named("io") ExecutorService executorService) - Parameters:
configuration- The configuration to use to authenticateldapSearchService- The search servicecontextBuilder- The context buildercontextAuthenticationMapper- The authentication mapperldapGroupProcessor- The group processorexecutorService- Executor Service
-
-
Method Details
-
authenticate
public org.reactivestreams.Publisher<AuthenticationResponse> authenticate(T requestContext, AuthenticationRequest<?, ?> authenticationRequest) Description copied from interface:AuthenticationProviderAuthenticates a user with the given request. If a successful authentication is returned, the object must be an instance ofAuthentication. Publishers MUST emit cold observables! This method will be called for all authenticators for each authentication request and it is assumed no work will be done until the publisher is subscribed to.- Specified by:
authenticatein interfaceAuthenticationProvider<T>- Parameters:
requestContext- The http requestauthenticationRequest- The credentials to authenticate- Returns:
- A publisher that emits 0 or 1 responses
-
rejectUnknownUser
protected AuthenticationResponse rejectUnknownUser(T requestContext, AuthenticationRequest<?, ?> authenticationRequest) Rejects an authentication request whose username did not match any directory entry.To prevent username enumeration (CWE-204) the response is indistinguishable from the one returned for a wrong password: the failure reason is always
AuthenticationFailureReason.CREDENTIALS_DO_NOT_MATCH, neverAuthenticationFailureReason.USER_NOT_FOUND, and a bind against a decoy DN is attempted so that an unknown username costs roughly the same client-side directory round trip as a known username with a wrong password. The outcome of that bind is ignored. The decoy DN isLdapConfiguration.SearchConfiguration.getDecoyDn()when configured, otherwise a random, non-existent entry under the search base.Only the client-side cost is equalised. A directory may still answer faster for a non-existent DN than for a wrong password; configure a real decoy entry where that matters.
- Parameters:
requestContext- The request contextauthenticationRequest- The authentication request, whose identity matched no entry- Returns:
- a
AuthenticationFailureReason.CREDENTIALS_DO_NOT_MATCHfailure - Since:
- 4.18.2
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-