mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '4.0.x' into 4.1.x
Closes gh-51639
This commit is contained in:
+1
-2
@@ -26,7 +26,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.PropertyMapper;
|
||||
import org.springframework.boot.web.server.Cookie;
|
||||
import org.springframework.boot.web.server.Cookie.SameSite;
|
||||
import org.springframework.boot.web.server.autoconfigure.ServerProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.ResponseCookie.ResponseCookieBuilder;
|
||||
@@ -76,7 +75,7 @@ public final class WebSessionIdResolverAutoConfiguration {
|
||||
map.from(cookie::getSecure).to(builder::secure);
|
||||
map.from(cookie::getMaxAge).to(builder::maxAge);
|
||||
map.from(cookie::getPartitioned).to(builder::partitioned);
|
||||
map.from(cookie::getSameSite).as(SameSite::attributeValue).always().to(builder::sameSite);
|
||||
map.from(cookie::getSameSite).to((sameSite) -> builder.sameSite(sameSite.attributeValue()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -88,6 +88,7 @@ import org.springframework.http.server.reactive.HttpHandler;
|
||||
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.server.MockServerWebExchange;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||
@@ -685,6 +686,16 @@ class WebFluxAutoConfigurationTests {
|
||||
this.contextRunner.run(assertMaxSessionsWithWebSession(defaultMaxSessions));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cookieSerializerUsesLaxSameSitePolicyByDefault() {
|
||||
this.contextRunner.run(assertExchangeWithSession((exchange) -> {
|
||||
MultiValueMap<String, ResponseCookie> stuff = exchange.getResponse().getCookies();
|
||||
List<ResponseCookie> cookies = stuff.get("SESSION");
|
||||
assertThat(cookies).isNotEmpty();
|
||||
assertThat(cookies).extracting(ResponseCookie::getSameSite).containsOnly("Lax");
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customSessionCookieConfigurationShouldBeApplied() {
|
||||
this.contextRunner.withPropertyValues("server.reactive.session.cookie.name:JSESSIONID",
|
||||
|
||||
Reference in New Issue
Block a user