Class AbstractUserDetailsReactiveAuthenticationManager
- java.lang.Object
-
- org.springframework.security.authentication.AbstractUserDetailsReactiveAuthenticationManager
-
- All Implemented Interfaces:
ReactiveAuthenticationManager
- Direct Known Subclasses:
UserDetailsRepositoryReactiveAuthenticationManager
public abstract class AbstractUserDetailsReactiveAuthenticationManager extends java.lang.Object implements ReactiveAuthenticationManager
A baseReactiveAuthenticationManager
that allows subclasses to override and work withUserDetails
objects.Upon successful validation, a
UsernamePasswordAuthenticationToken
will be created and returned to the caller. The token will include as its principal either aString
representation of the username, or theUserDetails
that was returned from the authentication repository.- Since:
- 5.2
-
-
Constructor Summary
Constructors Constructor Description AbstractUserDetailsReactiveAuthenticationManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Mono<Authentication>
authenticate(Authentication authentication)
Attempts to authenticate the providedAuthentication
protected abstract reactor.core.publisher.Mono<UserDetails>
retrieveUser(java.lang.String username)
Allows subclasses to retrieve theUserDetails
from an implementation-specific location.void
setPasswordEncoder(PasswordEncoder passwordEncoder)
ThePasswordEncoder
that is used for validating the password.void
setPostAuthenticationChecks(UserDetailsChecker postAuthenticationChecks)
Sets the strategy which will be used to validate the loaded UserDetails object after authentication occurs.void
setScheduler(reactor.core.scheduler.Scheduler scheduler)
Sets theScheduler
used by theUserDetailsRepositoryReactiveAuthenticationManager
.void
setUserDetailsPasswordService(ReactiveUserDetailsPasswordService userDetailsPasswordService)
Sets the service to use for upgrading passwords on successful authentication.
-
-
-
Method Detail
-
authenticate
public reactor.core.publisher.Mono<Authentication> authenticate(Authentication authentication)
Description copied from interface:ReactiveAuthenticationManager
Attempts to authenticate the providedAuthentication
- Specified by:
authenticate
in interfaceReactiveAuthenticationManager
- Parameters:
authentication
- theAuthentication
to test- Returns:
- if authentication is successful an
Authentication
is returned. If authentication cannot be determined, an empty Mono is returned. If authentication fails, a Mono error is returned.
-
setPasswordEncoder
public void setPasswordEncoder(PasswordEncoder passwordEncoder)
ThePasswordEncoder
that is used for validating the password. The default isPasswordEncoderFactories.createDelegatingPasswordEncoder()
- Parameters:
passwordEncoder
- thePasswordEncoder
to use. Cannot be null
-
setScheduler
public void setScheduler(reactor.core.scheduler.Scheduler scheduler)
Sets theScheduler
used by theUserDetailsRepositoryReactiveAuthenticationManager
. The default isSchedulers.newParallel(String)
because modern password encoding is a CPU intensive task that is non blocking. This means validation is bounded by the number of CPUs. Some applications may want to customize theScheduler
. For example, if users are stuck using the insecureNoOpPasswordEncoder
they might want to leverageSchedulers.immediate()
.- Parameters:
scheduler
- theScheduler
to use. Cannot be null.- Since:
- 5.0.6
-
setUserDetailsPasswordService
public void setUserDetailsPasswordService(ReactiveUserDetailsPasswordService userDetailsPasswordService)
Sets the service to use for upgrading passwords on successful authentication.- Parameters:
userDetailsPasswordService
- the service to use
-
setPostAuthenticationChecks
public void setPostAuthenticationChecks(UserDetailsChecker postAuthenticationChecks)
Sets the strategy which will be used to validate the loaded UserDetails object after authentication occurs.- Parameters:
postAuthenticationChecks
- TheUserDetailsChecker
- Since:
- 5.2
-
retrieveUser
protected abstract reactor.core.publisher.Mono<UserDetails> retrieveUser(java.lang.String username)
Allows subclasses to retrieve theUserDetails
from an implementation-specific location.- Parameters:
username
- The username to retrieve- Returns:
- the user information. If authentication fails, a Mono error is returned.
-
-