mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-30 15:52:15 +00:00
add setter for using a custom name for the rememberMeParameter
This commit is contained in:
parent
cd352f665b
commit
c8b79289c9
@ -162,6 +162,17 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>> extend
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HTTP parameter used to indicate to remember the user at time of login.
|
||||||
|
*
|
||||||
|
* @param rememberMeParameter the HTTP parameter used to indicate to remember the user
|
||||||
|
* @return the {@link RememberMeConfigurer} for further customization
|
||||||
|
*/
|
||||||
|
public RememberMeConfigurer<H> rememberMeParameter(String rememberMeParameter) {
|
||||||
|
this.rememberMeParameter = rememberMeParameter;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows control over the destination a remembered user is sent to when they are successfully authenticated.
|
* Allows control over the destination a remembered user is sent to when they are successfully authenticated.
|
||||||
* By default, the filter will just allow the current request to proceed, but if an
|
* By default, the filter will just allow the current request to proceed, but if an
|
||||||
|
@ -252,6 +252,24 @@ public class NamespaceRememberMeTests extends BaseSpringSpec {
|
|||||||
ReflectionTestUtils.getField(findFilter(RememberMeAuthenticationFilter).rememberMeServices, "useSecureCookie") == true
|
ReflectionTestUtils.getField(findFilter(RememberMeAuthenticationFilter).rememberMeServices, "useSecureCookie") == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
static class RememberMeParameterConfig extends BaseWebConfig {
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http
|
||||||
|
.formLogin()
|
||||||
|
.and()
|
||||||
|
.rememberMe()
|
||||||
|
.rememberMeParameter("rememberMe")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def "http/remember-me@remember-me-parameter"() {
|
||||||
|
when: "use custom rememberMeParameter"
|
||||||
|
loadConfig(RememberMeParameterConfig)
|
||||||
|
then: "custom rememberMeParameter will be used"
|
||||||
|
findFilter(RememberMeAuthenticationFilter).rememberMeServices.parameter == "rememberMe"
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class UseSecureCookieConfig extends BaseWebConfig {
|
static class UseSecureCookieConfig extends BaseWebConfig {
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user