Reactive Basic does not create session by default
Fixes: gh-4825
This commit is contained in:
parent
5f79fdd3eb
commit
942b51dba7
|
@ -27,6 +27,10 @@ public enum SecurityWebFiltersOrder {
|
||||||
* {@link org.springframework.security.web.server.csrf.CsrfWebFilter}
|
* {@link org.springframework.security.web.server.csrf.CsrfWebFilter}
|
||||||
*/
|
*/
|
||||||
CSRF,
|
CSRF,
|
||||||
|
/**
|
||||||
|
* {@link org.springframework.security.web.server.context.ReactorContextWebFilter}
|
||||||
|
*/
|
||||||
|
REACTOR_CONTEXT,
|
||||||
/**
|
/**
|
||||||
* Instance of AuthenticationWebFilter
|
* Instance of AuthenticationWebFilter
|
||||||
*/
|
*/
|
||||||
|
@ -36,10 +40,6 @@ public enum SecurityWebFiltersOrder {
|
||||||
*/
|
*/
|
||||||
FORM_LOGIN,
|
FORM_LOGIN,
|
||||||
AUTHENTICATION,
|
AUTHENTICATION,
|
||||||
/**
|
|
||||||
* {@link org.springframework.security.web.server.context.ReactorContextWebFilter}
|
|
||||||
*/
|
|
||||||
REACTOR_CONTEXT,
|
|
||||||
LOGIN_PAGE_GENERATING,
|
LOGIN_PAGE_GENERATING,
|
||||||
LOGOUT_PAGE_GENERATING,
|
LOGOUT_PAGE_GENERATING,
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -229,9 +229,6 @@ public class ServerHttpSecurity {
|
||||||
}
|
}
|
||||||
if(this.httpBasic != null) {
|
if(this.httpBasic != null) {
|
||||||
this.httpBasic.authenticationManager(this.authenticationManager);
|
this.httpBasic.authenticationManager(this.authenticationManager);
|
||||||
if(this.securityContextRepository != null) {
|
|
||||||
this.httpBasic.securityContextRepository(this.securityContextRepository);
|
|
||||||
}
|
|
||||||
this.httpBasic.configure(this);
|
this.httpBasic.configure(this);
|
||||||
}
|
}
|
||||||
if(this.formLogin != null) {
|
if(this.formLogin != null) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class ServerHttpSecurityTests {
|
||||||
.expectBody(String.class).consumeWith(b -> assertThat(b.getResponseBody()).isEqualTo("ok"))
|
.expectBody(String.class).consumeWith(b -> assertThat(b.getResponseBody()).isEqualTo("ok"))
|
||||||
.returnResult();
|
.returnResult();
|
||||||
|
|
||||||
assertThat(result.getResponseCookies().getFirst("SESSION")).isNotNull();
|
assertThat(result.getResponseCookies().getFirst("SESSION")).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.security.web.server.authentication;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.security.authentication.ReactiveAuthenticationManager;
|
import org.springframework.security.authentication.ReactiveAuthenticationManager;
|
||||||
|
@ -82,7 +83,8 @@ public class AuthenticationWebFilter implements WebFilter {
|
||||||
securityContext.setAuthentication(authentication);
|
securityContext.setAuthentication(authentication);
|
||||||
return this.securityContextRepository.save(exchange, securityContext)
|
return this.securityContextRepository.save(exchange, securityContext)
|
||||||
.then(this.authenticationSuccessHandler
|
.then(this.authenticationSuccessHandler
|
||||||
.onAuthenticationSuccess(webFilterExchange, authentication));
|
.onAuthenticationSuccess(webFilterExchange, authentication))
|
||||||
|
.subscriberContext(ReactiveSecurityContextHolder.withSecurityContext(Mono.just(securityContext)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecurityContextRepository(
|
public void setSecurityContextRepository(
|
||||||
|
|
Loading…
Reference in New Issue