|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -90,18 +90,10 @@ public class SessionAutoConfiguration {
|
|
|
|
|
SessionRepositoryFilterConfiguration.class })
|
|
|
|
|
static class ServletSessionConfiguration {
|
|
|
|
|
|
|
|
|
|
private final SpringSessionRememberMeServices springSessionRememberMeServices;
|
|
|
|
|
|
|
|
|
|
ServletSessionConfiguration(
|
|
|
|
|
ObjectProvider<SpringSessionRememberMeServices> springSessionRememberMeServices) {
|
|
|
|
|
this.springSessionRememberMeServices = springSessionRememberMeServices
|
|
|
|
|
.getIfAvailable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@Conditional(DefaultCookieSerializerCondition.class)
|
|
|
|
|
public DefaultCookieSerializer cookieSerializer(
|
|
|
|
|
ServerProperties serverProperties) {
|
|
|
|
|
public DefaultCookieSerializer cookieSerializer(ServerProperties serverProperties,
|
|
|
|
|
ObjectProvider<SpringSessionRememberMeServices> springSessionRememberMeServices) {
|
|
|
|
|
Cookie cookie = serverProperties.getServlet().getSession().getCookie();
|
|
|
|
|
DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
|
|
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
|
|
@ -112,10 +104,9 @@ public class SessionAutoConfiguration {
|
|
|
|
|
map.from(cookie::getSecure).to(cookieSerializer::setUseSecureCookie);
|
|
|
|
|
map.from(cookie::getMaxAge).to((maxAge) -> cookieSerializer
|
|
|
|
|
.setCookieMaxAge((int) maxAge.getSeconds()));
|
|
|
|
|
if (this.springSessionRememberMeServices != null) {
|
|
|
|
|
cookieSerializer.setRememberMeRequestAttribute(
|
|
|
|
|
SpringSessionRememberMeServices.REMEMBER_ME_LOGIN_ATTR);
|
|
|
|
|
}
|
|
|
|
|
springSessionRememberMeServices.ifAvailable((
|
|
|
|
|
rememberMeServices) -> cookieSerializer.setRememberMeRequestAttribute(
|
|
|
|
|
SpringSessionRememberMeServices.REMEMBER_ME_LOGIN_ATTR));
|
|
|
|
|
return cookieSerializer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|