Skip to content

Commit 1188a3b

Browse files
committed
Polish RememberMeConfigurer
Issue: gh-4140
1 parent b13f750 commit 1188a3b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurer.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ public RememberMeConfigurer<H> tokenRepository(
167167
/**
168168
* Sets the key to identify tokens created for remember me authentication. Default is
169169
* a secure randomly generated key.
170+
* If {@link #rememberMeServices(RememberMeServices)} is specified and is of type
171+
* {@link AbstractRememberMeServices}, then the default is the key set in
172+
* {@link AbstractRememberMeServices}.
170173
*
171174
* @param key the key to identify tokens created for remember me authentication
172175
* @return the {@link RememberMeConfigurer} for further customization
@@ -428,8 +431,12 @@ private UserDetailsService getUserDetailsService(H http) {
428431
}
429432

430433
/**
431-
* Gets the key to use for validating remember me tokens. Either the value passed into
432-
* {@link #key(String)}, or a secure random string if none was specified.
434+
* Gets the key to use for validating remember me tokens. If a value was passed into
435+
* {@link #key(String)}, then that is returned.
436+
* Alternatively, if a key was specified in the
437+
* {@link #rememberMeServices(RememberMeServices)}}, then that is returned.
438+
* If no key was specified in either of those cases, then a secure random string is
439+
* generated.
433440
*
434441
* @return the remember me key to use
435442
*/

config/src/test/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurerTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception
456456
}
457457

458458
@Test
459-
public void getWhenRememberMeCookieThenAuthenticationIsRememberMeAuthenticationTokenWithFallbackKeyConfiguration()
459+
public void getWhenRememberMeCookieAndNoKeyConfiguredThenKeyFromRememberMeServicesIsUsed()
460460
throws Exception {
461461
this.spring.register(FallbackRememberMeKeyConfig.class).autowire();
462462

0 commit comments

Comments
 (0)