Skip to content

Commit 3e1616c

Browse files
committed
Remove BearerTokenAuthenticationWebFilter
Closes gh-9377
1 parent c03ba45 commit 3e1616c

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,7 +52,6 @@
5252
import org.springframework.security.authorization.ReactiveAuthorizationManager;
5353
import org.springframework.security.config.Customizer;
5454
import org.springframework.security.core.Authentication;
55-
import org.springframework.security.core.AuthenticationException;
5655
import org.springframework.security.core.GrantedAuthority;
5756
import org.springframework.security.core.authority.AuthorityUtils;
5857
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
@@ -107,7 +106,6 @@
107106
import org.springframework.security.web.server.MatcherSecurityWebFilterChain;
108107
import org.springframework.security.web.server.SecurityWebFilterChain;
109108
import org.springframework.security.web.server.ServerAuthenticationEntryPoint;
110-
import org.springframework.security.web.server.WebFilterExchange;
111109
import org.springframework.security.web.server.authentication.AnonymousAuthenticationWebFilter;
112110
import org.springframework.security.web.server.authentication.AuthenticationConverterServerWebExchangeMatcher;
113111
import org.springframework.security.web.server.authentication.AuthenticationWebFilter;
@@ -3780,30 +3778,6 @@ public ServerHttpSecurity and() {
37803778
return ServerHttpSecurity.this;
37813779
}
37823780

3783-
private class BearerTokenAuthenticationWebFilter extends AuthenticationWebFilter {
3784-
3785-
private ServerAuthenticationFailureHandler authenticationFailureHandler;
3786-
3787-
BearerTokenAuthenticationWebFilter(ReactiveAuthenticationManager authenticationManager) {
3788-
super(authenticationManager);
3789-
}
3790-
3791-
@Override
3792-
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
3793-
WebFilterExchange webFilterExchange = new WebFilterExchange(exchange, chain);
3794-
return super.filter(exchange, chain).onErrorResume(AuthenticationException.class,
3795-
(e) -> this.authenticationFailureHandler.onAuthenticationFailure(webFilterExchange, e));
3796-
}
3797-
3798-
@Override
3799-
public void setAuthenticationFailureHandler(
3800-
ServerAuthenticationFailureHandler authenticationFailureHandler) {
3801-
super.setAuthenticationFailureHandler(authenticationFailureHandler);
3802-
this.authenticationFailureHandler = authenticationFailureHandler;
3803-
}
3804-
3805-
}
3806-
38073781
/**
38083782
* Configures JWT Resource Server Support
38093783
*/
@@ -3880,7 +3854,7 @@ public OAuth2ResourceServerSpec and() {
38803854

38813855
protected void configure(ServerHttpSecurity http) {
38823856
ReactiveAuthenticationManager authenticationManager = getAuthenticationManager();
3883-
AuthenticationWebFilter oauth2 = new BearerTokenAuthenticationWebFilter(authenticationManager);
3857+
AuthenticationWebFilter oauth2 = new AuthenticationWebFilter(authenticationManager);
38843858
oauth2.setServerAuthenticationConverter(OAuth2ResourceServerSpec.this.bearerTokenConverter);
38853859
oauth2.setAuthenticationFailureHandler(
38863860
new ServerAuthenticationEntryPointFailureHandler(OAuth2ResourceServerSpec.this.entryPoint));
@@ -3985,7 +3959,7 @@ protected ReactiveOpaqueTokenIntrospector getIntrospector() {
39853959

39863960
protected void configure(ServerHttpSecurity http) {
39873961
ReactiveAuthenticationManager authenticationManager = getAuthenticationManager();
3988-
AuthenticationWebFilter oauth2 = new BearerTokenAuthenticationWebFilter(authenticationManager);
3962+
AuthenticationWebFilter oauth2 = new AuthenticationWebFilter(authenticationManager);
39893963
oauth2.setServerAuthenticationConverter(OAuth2ResourceServerSpec.this.bearerTokenConverter);
39903964
oauth2.setAuthenticationFailureHandler(
39913965
new ServerAuthenticationEntryPointFailureHandler(OAuth2ResourceServerSpec.this.entryPoint));

0 commit comments

Comments
 (0)