Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class RememberMeConfigurer
- Object
- SecurityConfigurer
- RememberMeConfigurer
Remember-me: a cookie that signs a returning user in.
http.formLogin(Customizer.withDefaults())
.rememberMe(remember -> remember
.tokenRepository(new JdbcTokenRepository(dataSource))
.tokenValiditySeconds(30 * 24 * 3600));
A user who ticks remember-me on the login form is given the cookie, and
is signed in by it on a later visit without a session. They are then
authenticated but not fully: fullyAuthenticated() in the authorization
rules, and isFullyAuthenticated() in a @PreAuthorize, refuse them until
they sign in again. Signing out deletes the cookie and forgets the user in
every browser.
On a chain with a second factor – HttpSecurity.mfa – the cookie of a
user who has one signs them in only if it was issued by a sign-in that
passed it. One issued for a password alone, before the user enrolled, is
withdrawn when it is presented, and the user signs in again; see
MfaConfigurer.
Tokens are kept by a PersistentTokenRepository: the one given here, the
application’s bean of that type, or one in memory – which forgets everyone
when the server restarts, and is no use to a deployment of several
processes. Users are found through the chain’s UserDetailsService.
See PersistentTokenBasedRememberMeServices for the cookie itself.
Methods
Inherited methods
Method details
rememberMeServices
public RememberMeConfigurer rememberMeServices(RememberMeServices rememberMeServices)tokenRepository
public RememberMeConfigurer tokenRepository(PersistentTokenRepository tokenRepository)userDetailsService
public RememberMeConfigurer userDetailsService(UserDetailsService userDetailsService)key
public RememberMeConfigurer key(String key)rememberMeCookieName
public RememberMeConfigurer rememberMeCookieName(String rememberMeCookieName)remember-me unless set.rememberMeParameter
public RememberMeConfigurer rememberMeParameter(String rememberMeParameter)remember-me unless set.tokenValiditySeconds
public RememberMeConfigurer tokenValiditySeconds(int tokenValiditySeconds)alwaysRemember
public RememberMeConfigurer alwaysRemember(boolean alwaysRemember)useSecureCookie
public RememberMeConfigurer useSecureCookie(boolean useSecureCookie)Secure; when the request was, unless set.sameSite
public RememberMeConfigurer sameSite(String sameSite)SameSite: Lax unless set; null for none.getRememberMeServices
public RememberMeServices getRememberMeServices()loginSuccess on. Available once the chain is being built.init
public void init(HttpSecurity http)configure
public void configure(HttpSecurity http)