|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2020 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
52 | 52 | import org.springframework.security.authorization.ReactiveAuthorizationManager;
|
53 | 53 | import org.springframework.security.config.Customizer;
|
54 | 54 | import org.springframework.security.core.Authentication;
|
55 |
| -import org.springframework.security.core.AuthenticationException; |
56 | 55 | import org.springframework.security.core.GrantedAuthority;
|
57 | 56 | import org.springframework.security.core.authority.AuthorityUtils;
|
58 | 57 | import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
|
|
107 | 106 | import org.springframework.security.web.server.MatcherSecurityWebFilterChain;
|
108 | 107 | import org.springframework.security.web.server.SecurityWebFilterChain;
|
109 | 108 | import org.springframework.security.web.server.ServerAuthenticationEntryPoint;
|
110 |
| -import org.springframework.security.web.server.WebFilterExchange; |
111 | 109 | import org.springframework.security.web.server.authentication.AnonymousAuthenticationWebFilter;
|
112 | 110 | import org.springframework.security.web.server.authentication.AuthenticationConverterServerWebExchangeMatcher;
|
113 | 111 | import org.springframework.security.web.server.authentication.AuthenticationWebFilter;
|
@@ -3780,30 +3778,6 @@ public ServerHttpSecurity and() {
|
3780 | 3778 | return ServerHttpSecurity.this;
|
3781 | 3779 | }
|
3782 | 3780 |
|
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 |
| - |
3807 | 3781 | /**
|
3808 | 3782 | * Configures JWT Resource Server Support
|
3809 | 3783 | */
|
@@ -3880,7 +3854,7 @@ public OAuth2ResourceServerSpec and() {
|
3880 | 3854 |
|
3881 | 3855 | protected void configure(ServerHttpSecurity http) {
|
3882 | 3856 | ReactiveAuthenticationManager authenticationManager = getAuthenticationManager();
|
3883 |
| - AuthenticationWebFilter oauth2 = new BearerTokenAuthenticationWebFilter(authenticationManager); |
| 3857 | + AuthenticationWebFilter oauth2 = new AuthenticationWebFilter(authenticationManager); |
3884 | 3858 | oauth2.setServerAuthenticationConverter(OAuth2ResourceServerSpec.this.bearerTokenConverter);
|
3885 | 3859 | oauth2.setAuthenticationFailureHandler(
|
3886 | 3860 | new ServerAuthenticationEntryPointFailureHandler(OAuth2ResourceServerSpec.this.entryPoint));
|
@@ -3985,7 +3959,7 @@ protected ReactiveOpaqueTokenIntrospector getIntrospector() {
|
3985 | 3959 |
|
3986 | 3960 | protected void configure(ServerHttpSecurity http) {
|
3987 | 3961 | ReactiveAuthenticationManager authenticationManager = getAuthenticationManager();
|
3988 |
| - AuthenticationWebFilter oauth2 = new BearerTokenAuthenticationWebFilter(authenticationManager); |
| 3962 | + AuthenticationWebFilter oauth2 = new AuthenticationWebFilter(authenticationManager); |
3989 | 3963 | oauth2.setServerAuthenticationConverter(OAuth2ResourceServerSpec.this.bearerTokenConverter);
|
3990 | 3964 | oauth2.setAuthenticationFailureHandler(
|
3991 | 3965 | new ServerAuthenticationEntryPointFailureHandler(OAuth2ResourceServerSpec.this.entryPoint));
|
|
0 commit comments