From fc658d10d3f613c7386b10deb0cadcc05869280d Mon Sep 17 00:00:00 2001 From: DingHao Date: Tue, 6 Feb 2024 10:56:29 +0800 Subject: [PATCH] fix security filter sort in javadoc Closes gh-14531 --- .../annotation/web/HttpSecurityBuilder.java | 23 +++++++++++++++---- .../web/builders/FilterOrderRegistration.java | 3 +-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/HttpSecurityBuilder.java b/config/src/main/java/org/springframework/security/config/annotation/web/HttpSecurityBuilder.java index edb7a47114..8f49e10838 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/HttpSecurityBuilder.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/HttpSecurityBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ import org.springframework.security.config.annotation.SecurityConfigurer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.oauth2.server.resource.web.authentication.BearerTokenAuthenticationFilter; -import org.springframework.security.openid.OpenIDAuthenticationFilter; import org.springframework.security.web.DefaultSecurityFilterChain; import org.springframework.security.web.access.ExceptionTranslationFilter; import org.springframework.security.web.access.channel.ChannelProcessingFilter; +import org.springframework.security.web.access.intercept.AuthorizationFilter; import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; @@ -38,7 +38,11 @@ import org.springframework.security.web.authentication.rememberme.RememberMeAuth import org.springframework.security.web.authentication.switchuser.SwitchUserFilter; import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; import org.springframework.security.web.authentication.www.DigestAuthenticationFilter; +import org.springframework.security.web.context.SecurityContextHolderFilter; import org.springframework.security.web.context.SecurityContextPersistenceFilter; +import org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter; +import org.springframework.security.web.csrf.CsrfFilter; +import org.springframework.security.web.header.HeaderWriterFilter; import org.springframework.security.web.jaasapi.JaasApiIntegrationFilter; import org.springframework.security.web.savedrequest.RequestCacheAwareFilter; import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter; @@ -46,6 +50,7 @@ import org.springframework.security.web.session.ConcurrentSessionFilter; import org.springframework.security.web.session.DisableEncodeUrlFilter; import org.springframework.security.web.session.ForceEagerSessionCreationFilter; import org.springframework.security.web.session.SessionManagementFilter; +import org.springframework.web.filter.CorsFilter; /** * @param @@ -127,17 +132,25 @@ public interface HttpSecurityBuilder> * The ordering of the Filters is: * *
    - *
  • {@link ForceEagerSessionCreationFilter}
  • *
  • {@link DisableEncodeUrlFilter}
  • + *
  • {@link ForceEagerSessionCreationFilter}
  • *
  • {@link ChannelProcessingFilter}
  • + *
  • {@link WebAsyncManagerIntegrationFilter}
  • + *
  • {@link SecurityContextHolderFilter}
  • *
  • {@link SecurityContextPersistenceFilter}
  • + *
  • {@link HeaderWriterFilter}
  • + *
  • {@link CorsFilter}
  • + *
  • {@link CsrfFilter}
  • *
  • {@link LogoutFilter}
  • + *
  • {@link org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter}
  • + *
  • {@link org.springframework.security.saml2.provider.service.web.Saml2WebSsoAuthenticationRequestFilter}
  • *
  • {@link X509AuthenticationFilter}
  • *
  • {@link AbstractPreAuthenticatedProcessingFilter}
  • *
  • CasAuthenticationFilter
  • + *
  • {@link org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter}
  • + *
  • {@link org.springframework.security.saml2.provider.service.web.authentication.Saml2WebSsoAuthenticationFilter}
  • *
  • {@link UsernamePasswordAuthenticationFilter}
  • - *
  • {@link OpenIDAuthenticationFilter}
  • *
  • {@link org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter}
  • *
  • {@link org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter}
  • *
  • {@link ConcurrentSessionFilter}
  • @@ -149,9 +162,11 @@ public interface HttpSecurityBuilder> *
  • {@link JaasApiIntegrationFilter}
  • *
  • {@link RememberMeAuthenticationFilter}
  • *
  • {@link AnonymousAuthenticationFilter}
  • + *
  • {@link org.springframework.security.oauth2.client.web.OAuth2AuthorizationCodeGrantFilter}
  • *
  • {@link SessionManagementFilter}
  • *
  • {@link ExceptionTranslationFilter}
  • *
  • {@link FilterSecurityInterceptor}
  • + *
  • {@link AuthorizationFilter}
  • *
  • {@link SwitchUserFilter}
  • *
* @param filter the {@link Filter} to add diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/builders/FilterOrderRegistration.java b/config/src/main/java/org/springframework/security/config/annotation/web/builders/FilterOrderRegistration.java index 0103982ebc..174256b3a6 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/builders/FilterOrderRegistration.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/builders/FilterOrderRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -97,7 +97,6 @@ final class FilterOrderRegistration { order.next()); put(UsernamePasswordAuthenticationFilter.class, order.next()); order.next(); // gh-8105 - this.filterToOrder.put("org.springframework.security.openid.OpenIDAuthenticationFilter", order.next()); put(DefaultLoginPageGeneratingFilter.class, order.next()); put(DefaultLogoutPageGeneratingFilter.class, order.next()); put(ConcurrentSessionFilter.class, order.next());