Class EmailLinkAuthenticationProvider
java.lang.Object
org.jwcarman.who.emaillink.EmailLinkAuthenticationProvider
- All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider
public class EmailLinkAuthenticationProvider
extends Object
implements org.springframework.security.authentication.AuthenticationProvider
Authenticates an email sign-in, by the token from the link or by the address and the code typed
by hand, then resolves its email credential to an active identity. Every failure is the same
InvalidOneTimeTokenException, whatever the cause.
A code attempt is counted before the code is compared, so a token allows at most EmailLinkSettings.codeMaxAttempts() guesses. When no attempt is available, a dummy hash is still
computed, so the work done does not reveal whether the address has a live token.
Each failure publishes SignInFailed with its server-side reason, and logs one DEBUG
line; the address appears in no log line above DEBUG. A success is returned as a WhoAuthenticationToken that carries its SignInMethod, and is published by who's success
handler once the session is saved, not here.
-
Constructor Summary
ConstructorsConstructorDescriptionEmailLinkAuthenticationProvider(EmailLinkTokenRepository repository, EmailLinkSettings settings, WhoService whoService, Clock clock) Creates a new provider that publishes no events.EmailLinkAuthenticationProvider(EmailLinkTokenRepository repository, EmailLinkSettings settings, WhoService whoService, Clock clock, WhoEventPublisher eventPublisher) Creates a new provider. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.core.Authenticationauthenticate(org.springframework.security.core.Authentication authentication) boolean
-
Constructor Details
-
EmailLinkAuthenticationProvider
public EmailLinkAuthenticationProvider(EmailLinkTokenRepository repository, EmailLinkSettings settings, WhoService whoService, Clock clock) Creates a new provider that publishes no events.- Parameters:
repository- the token repositorysettings- the email-link settingswhoService- resolves credentials to principalsclock- the clock
-
EmailLinkAuthenticationProvider
public EmailLinkAuthenticationProvider(EmailLinkTokenRepository repository, EmailLinkSettings settings, WhoService whoService, Clock clock, WhoEventPublisher eventPublisher) Creates a new provider.- Parameters:
repository- the token repositorysettings- the email-link settingswhoService- resolves credentials to principalsclock- the clockeventPublisher- whereSignInFailedis published
-
-
Method Details
-
authenticate
public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication) - Specified by:
authenticatein interfaceorg.springframework.security.authentication.AuthenticationProvider
-
supports
- Specified by:
supportsin interfaceorg.springframework.security.authentication.AuthenticationProvider
-