Use Server<Description>AuthenticationConverter
Issue gh-4615
This commit is contained in:
@@ -26,8 +26,8 @@ import org.springframework.security.authorization.AuthorizationDecision;
|
||||
import org.springframework.security.authorization.ReactiveAuthorizationManager;
|
||||
import org.springframework.security.web.server.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.server.DelegatingAuthenticationEntryPoint;
|
||||
import org.springframework.security.web.server.FormLoginAuthenticationConverter;
|
||||
import org.springframework.security.web.server.HttpBasicAuthenticationConverter;
|
||||
import org.springframework.security.web.server.ServerFormLoginAuthenticationConverter;
|
||||
import org.springframework.security.web.server.ServerHttpBasicAuthenticationConverter;
|
||||
import org.springframework.security.web.server.MatcherSecurityWebFilterChain;
|
||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
import org.springframework.security.web.server.authentication.AuthenticationEntryPointFailureHandler;
|
||||
@@ -355,7 +355,7 @@ public class HttpSecurity {
|
||||
AuthenticationWebFilter authenticationFilter = new AuthenticationWebFilter(
|
||||
this.authenticationManager);
|
||||
authenticationFilter.setAuthenticationFailureHandler(new AuthenticationEntryPointFailureHandler(this.entryPoint));
|
||||
authenticationFilter.setAuthenticationConverter(new HttpBasicAuthenticationConverter());
|
||||
authenticationFilter.setAuthenticationConverter(new ServerHttpBasicAuthenticationConverter());
|
||||
if(this.securityContextRepository != null) {
|
||||
authenticationFilter.setSecurityContextRepository(this.securityContextRepository);
|
||||
}
|
||||
@@ -433,7 +433,7 @@ public class HttpSecurity {
|
||||
this.authenticationManager);
|
||||
authenticationFilter.setRequiresAuthenticationMatcher(this.requiresAuthenticationMatcher);
|
||||
authenticationFilter.setAuthenticationFailureHandler(this.authenticationFailureHandler);
|
||||
authenticationFilter.setAuthenticationConverter(new FormLoginAuthenticationConverter());
|
||||
authenticationFilter.setAuthenticationConverter(new ServerFormLoginAuthenticationConverter());
|
||||
authenticationFilter.setAuthenticationSuccessHandler(new RedirectAuthenticationSuccessHandler("/"));
|
||||
authenticationFilter.setSecurityContextRepository(this.securityContextRepository);
|
||||
http.addFilterAt(authenticationFilter, SecurityWebFiltersOrder.FORM_LOGIN);
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
public class FormLoginAuthenticationConverter implements Function<ServerWebExchange,Mono<Authentication>> {
|
||||
public class ServerFormLoginAuthenticationConverter implements Function<ServerWebExchange,Mono<Authentication>> {
|
||||
|
||||
private String usernameParameter = "username";
|
||||
|
||||
@@ -32,7 +32,7 @@ import reactor.core.publisher.Mono;
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
public class HttpBasicAuthenticationConverter implements Function<ServerWebExchange,Mono<Authentication>> {
|
||||
public class ServerHttpBasicAuthenticationConverter implements Function<ServerWebExchange,Mono<Authentication>> {
|
||||
|
||||
public static final String BASIC = "Basic ";
|
||||
|
||||
@@ -23,8 +23,7 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.security.authentication.ReactiveAuthenticationManager;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextImpl;
|
||||
import org.springframework.security.web.server.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.server.HttpBasicAuthenticationConverter;
|
||||
import org.springframework.security.web.server.ServerHttpBasicAuthenticationConverter;
|
||||
import org.springframework.security.web.server.WebFilterExchange;
|
||||
import org.springframework.security.web.server.authentication.www.HttpBasicAuthenticationEntryPoint;
|
||||
import org.springframework.security.web.server.context.SecurityContextRepository;
|
||||
@@ -48,7 +47,7 @@ public class AuthenticationWebFilter implements WebFilter {
|
||||
|
||||
private AuthenticationSuccessHandler authenticationSuccessHandler = new WebFilterChainAuthenticationSuccessHandler();
|
||||
|
||||
private Function<ServerWebExchange,Mono<Authentication>> authenticationConverter = new HttpBasicAuthenticationConverter();
|
||||
private Function<ServerWebExchange,Mono<Authentication>> authenticationConverter = new ServerHttpBasicAuthenticationConverter();
|
||||
|
||||
private AuthenticationFailureHandler authenticationFailureHandler = new AuthenticationEntryPointFailureHandler(new HttpBasicAuthenticationEntryPoint());
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ import static org.mockito.Mockito.when;
|
||||
* @since 5.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class FormLoginAuthenticationConverterTests {
|
||||
public class ServerFormLoginAuthenticationConverterTests {
|
||||
@Mock
|
||||
private ServerWebExchange exchange;
|
||||
|
||||
private MultiValueMap<String,String> data = new LinkedMultiValueMap<>();
|
||||
|
||||
private FormLoginAuthenticationConverter converter = new FormLoginAuthenticationConverter();
|
||||
private ServerFormLoginAuthenticationConverter converter = new ServerFormLoginAuthenticationConverter();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -22,7 +22,6 @@ import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -30,9 +29,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
public class HttpBasicAuthenticationConverterTests {
|
||||
public class ServerHttpBasicAuthenticationConverterTests {
|
||||
|
||||
HttpBasicAuthenticationConverter converter = new HttpBasicAuthenticationConverter();
|
||||
ServerHttpBasicAuthenticationConverter converter = new ServerHttpBasicAuthenticationConverter();
|
||||
MockServerHttpRequest.BaseBuilder<?> request = MockServerHttpRequest.get("/");
|
||||
|
||||
@Test
|
||||
Reference in New Issue
Block a user