From 5f64f53c3f931ae98e93c58648fa4afb057d369e Mon Sep 17 00:00:00 2001
From: Phillip Webb
spring-security-oauth2.
- * @throws Exception
* @see OpenIDLoginConfigurer
*/
public OpenIDLoginConfigurerspring-security-oauth2.
- * @return the {@link HttpSecurity} for further customizations
- * @throws Exception
+ * @see OpenIDLoginConfigurer
*/
public HttpSecurity openidLogin(Customizer
- *
- * @since 5.2
* @return the {@link Saml2LoginConfigurer} for further customizations
* @throws Exception
+ * @since 5.2
*/
public Saml2LoginConfigurer
- *
- * @since 5.2
* @param saml2LoginCustomizer the {@link Customizer} to provide more options for the
* {@link Saml2LoginConfigurer}
* @return the {@link HttpSecurity} for further customizations
* @throws Exception
+ * @since 5.2
*/
public HttpSecurity saml2Login(Customizer
* Referrer-Policy: no-referrer *- * - * @see ReferrerPolicyHeaderWriter - * @since 4.2 * @return the {@link ReferrerPolicyConfig} for additional configuration + * @since 4.2 + * @see ReferrerPolicyHeaderWriter */ public ReferrerPolicyConfig referrerPolicy() { this.referrerPolicy.writer = new ReferrerPolicyHeaderWriter(); @@ -967,11 +964,10 @@ public class HeadersConfigurer
* Configuration is provided to the {@link FeaturePolicyHeaderWriter} which is
* responsible for writing the header.
- *
- * @see FeaturePolicyHeaderWriter
- * @since 5.1
* @return the {@link FeaturePolicyConfig} for additional configuration
* @throws IllegalArgumentException if policyDirectives is {@code null} or empty
+ * @since 5.1
+ * @see FeaturePolicyHeaderWriter
*/
public FeaturePolicyConfig featurePolicy(String policyDirectives) {
this.featurePolicy.writer = new FeaturePolicyHeaderWriter(policyDirectives);
diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java
index da0028a54f..7b9aa5132a 100644
--- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java
+++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java
@@ -143,11 +143,10 @@ public final class LogoutConfigurerlogoutRequestMatcher(new AntPathRequestMatcher(logoutUrl, "GET"));
*
spring-security-oauth2.
- * @since 3.2
*/
public final class OpenIDLoginConfigurer
* @EnableWebFluxSecurity
* public class MyExplicitSecurityConfiguration {
- * // @formatter:off
* @Bean
* public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
* http
@@ -65,9 +65,7 @@ import java.lang.annotation.Target;
* .formLogin();
* return http.build();
* }
- * // @formatter:on
*
- * // @formatter:off
* @Bean
* public MapReactiveUserDetailsService userDetailsService() {
* UserDetails user = User.withDefaultPasswordEncoder()
@@ -77,8 +75,8 @@ import java.lang.annotation.Target;
* .build();
* return new MapReactiveUserDetailsService(user);
* }
- * // @formatter:on
* }
+ *
*
* @author Rob Winch
* @since 5.0
diff --git a/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java b/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java
index 5dd453fca2..dc02c12412 100644
--- a/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java
+++ b/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java
@@ -447,13 +447,13 @@ final class AuthenticationConfigBuilder {
/**
* Parses OpenID 1.0 and 2.0 - related parts of configuration xmls
+ * @param sessionStrategy sessionStrategy
+ * @param openIDLoginElt the element from the xml file
+ * @return the parsed filter as rootBeanDefinition
* @deprecated The OpenID 1.0 and 2.0 protocols have been deprecated and users are
* encouraged to
* migrate to OpenID Connect, which is
* supported by spring-security-oauth2.
- * @param sessionStrategy sessionStrategy
- * @param openIDLoginElt the element from the xml file
- * @return the parsed filter as rootBeanDefinition
*/
private RootBeanDefinition parseOpenIDFilter(BeanReference sessionStrategy, Element openIDLoginElt) {
RootBeanDefinition openIDFilter;
diff --git a/config/src/main/java/org/springframework/security/config/http/OAuth2ResourceServerBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/OAuth2ResourceServerBeanDefinitionParser.java
index 326fc70713..e460c3365b 100644
--- a/config/src/main/java/org/springframework/security/config/http/OAuth2ResourceServerBeanDefinitionParser.java
+++ b/config/src/main/java/org/springframework/security/config/http/OAuth2ResourceServerBeanDefinitionParser.java
@@ -55,8 +55,8 @@ import org.springframework.util.xml.DomUtils;
* A {@link BeanDefinitionParser} for <http>'s <oauth2-resource-server>
* element.
*
- * @since 5.3
* @author Josh Cummings
+ * @since 5.3
*/
final class OAuth2ResourceServerBeanDefinitionParser implements BeanDefinitionParser {
diff --git a/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java b/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java
index a031988e83..9216cbd9d8 100644
--- a/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java
+++ b/config/src/main/java/org/springframework/security/config/ldap/ContextSourceSettingPostProcessor.java
@@ -26,10 +26,10 @@ import org.springframework.util.ClassUtils;
/**
* Checks for the presence of a ContextSource instance. Also supplies the standard
- * reference to any unconfigured @EnableWebFluxSecurity public class
- * MyMinimalSecurityConfiguration {
+ *
+ * @EnableWebFluxSecurity
+ * public class MyMinimalSecurityConfiguration {
*
- * @Bean public MapReactiveUserDetailsService userDetailsService() { UserDetails user
- * = User.withDefaultPasswordEncoder() .username("user") .password("password")
- * .roles("USER") .build(); return new MapReactiveUserDetailsService(user); } }
+ * @Bean
+ * public MapReactiveUserDetailsService userDetailsService() {
+ * UserDetails user = User.withDefaultPasswordEncoder()
+ * .username("user")
+ * .password("password")
+ * .roles("USER")
+ * .build();
+ * return new MapReactiveUserDetailsService(user);
+ * }
+ * }
+ *
*
* Below is the same as our minimal configuration, but explicitly declaring the
* {@code ServerHttpSecurity}.
*
- * @EnableWebFluxSecurity public class
- * MyExplicitSecurityConfiguration { @Bean public SecurityWebFilterChain
- * springSecurityFilterChain(ServerHttpSecurity http) { http .authorizeExchange()
- * .anyExchange().authenticated() .and() .httpBasic().and() .formLogin(); return
- * http.build(); }
+ *
+ * @EnableWebFluxSecurity
+ * public class MyExplicitSecurityConfiguration {
*
- * @Bean public MapReactiveUserDetailsService userDetailsService() { UserDetails user
- * = User.withDefaultPasswordEncoder() .username("user") .password("password")
- * .roles("USER") .build(); return new MapReactiveUserDetailsService(user); } }
+ * @Bean
+ * public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
+ * http
+ * .authorizeExchange()
+ * .anyExchange().authenticated()
+ * .and()
+ * .httpBasic().and()
+ * .formLogin();
+ * return http.build();
+ * }
+ *
+ * @Bean
+ * public MapReactiveUserDetailsService userDetailsService() {
+ * UserDetails user = User.withDefaultPasswordEncoder()
+ * .username("user")
+ * .password("password")
+ * .roles("USER")
+ * .build();
+ * return new MapReactiveUserDetailsService(user);
+ * }
+ * }
+ *
*
* @author Rob Winch
* @author Vedran Pavic
@@ -829,11 +855,10 @@ public class ServerHttpSecurity {
* Note that if extractor is not specified, {@link SubjectDnX509PrincipalExtractor}
* will be used. If authenticationManager is not specified,
* {@link ReactivePreAuthenticatedAuthenticationManager} will be used.
- *
- * @since 5.2
* @param x509Customizer the {@link Customizer} to provide more options for the
* {@link X509Spec}
* @return the {@link ServerHttpSecurity} to customize
+ * @since 5.2
*/
public ServerHttpSecurity x509(Customizer x509Customizer) {
if (this.x509 == null) {
@@ -994,10 +1019,9 @@ public class ServerHttpSecurity {
* The {@link ServerSecurityContextRepository} used to save the
* {@code Authentication}. Defaults to
* {@link WebSessionServerSecurityContextRepository}.
- *
- * @since 5.2
* @param securityContextRepository the repository to use
* @return the {@link OAuth2LoginSpec} to continue configuring
+ * @since 5.2
*/
public OAuth2LoginSpec securityContextRepository(ServerSecurityContextRepository securityContextRepository) {
this.securityContextRepository = securityContextRepository;
@@ -1008,10 +1032,9 @@ public class ServerHttpSecurity {
* The {@link ServerAuthenticationSuccessHandler} used after authentication
* success. Defaults to {@link RedirectServerAuthenticationSuccessHandler}
* redirecting to "/".
- *
- * @since 5.2
* @param authenticationSuccessHandler the success handler to use
* @return the {@link OAuth2LoginSpec} to customize
+ * @since 5.2
*/
public OAuth2LoginSpec authenticationSuccessHandler(
ServerAuthenticationSuccessHandler authenticationSuccessHandler) {
@@ -1024,10 +1047,9 @@ public class ServerHttpSecurity {
* The {@link ServerAuthenticationFailureHandler} used after authentication
* failure. Defaults to {@link RedirectServerAuthenticationFailureHandler}
* redirecting to "/login?error".
- *
- * @since 5.2
* @param authenticationFailureHandler the failure handler to use
* @return the {@link OAuth2LoginSpec} to customize
+ * @since 5.2
*/
public OAuth2LoginSpec authenticationFailureHandler(
ServerAuthenticationFailureHandler authenticationFailureHandler) {
@@ -1121,11 +1143,10 @@ public class ServerHttpSecurity {
/**
* Sets the repository to use for storing {@link OAuth2AuthorizationRequest}'s.
- *
- * @since 5.2
* @param authorizationRequestRepository the repository to use for storing
* {@link OAuth2AuthorizationRequest}'s
* @return the {@link OAuth2LoginSpec} for further configuration
+ * @since 5.2
*/
public OAuth2LoginSpec authorizationRequestRepository(
ServerAuthorizationRequestRepository authorizationRequestRepository) {
@@ -1135,11 +1156,10 @@ public class ServerHttpSecurity {
/**
* Sets the resolver used for resolving {@link OAuth2AuthorizationRequest}'s.
- *
- * @since 5.2
* @param authorizationRequestResolver the resolver used for resolving
* {@link OAuth2AuthorizationRequest}'s
* @return the {@link OAuth2LoginSpec} for further configuration
+ * @since 5.2
*/
public OAuth2LoginSpec authorizationRequestResolver(
ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver) {
@@ -1150,11 +1170,10 @@ public class ServerHttpSecurity {
/**
* Sets the {@link ServerWebExchangeMatcher matcher} used for determining if the
* request is an authentication request.
- *
- * @since 5.2
* @param authenticationMatcher the {@link ServerWebExchangeMatcher matcher} used
* for determining if the request is an authentication request
* @return the {@link OAuth2LoginSpec} for further configuration
+ * @since 5.2
*/
public OAuth2LoginSpec authenticationMatcher(ServerWebExchangeMatcher authenticationMatcher) {
this.authenticationMatcher = authenticationMatcher;
@@ -1499,11 +1518,10 @@ public class ServerHttpSecurity {
/**
* Sets the repository to use for storing {@link OAuth2AuthorizationRequest}'s.
- *
- * @since 5.2
* @param authorizationRequestRepository the repository to use for storing
* {@link OAuth2AuthorizationRequest}'s
* @return the {@link OAuth2ClientSpec} to customize
+ * @since 5.2
*/
public OAuth2ClientSpec authorizationRequestRepository(
ServerAuthorizationRequestRepository authorizationRequestRepository) {
@@ -3689,8 +3707,8 @@ public class ServerHttpSecurity {
/**
* Configures {@code Content-Security-Policy} response header.
*
- * @see #contentSecurityPolicy(String)
* @since 5.1
+ * @see #contentSecurityPolicy(String)
*/
public class ContentSecurityPolicySpec {
@@ -3740,8 +3758,8 @@ public class ServerHttpSecurity {
/**
* Configures {@code Feature-Policy} response header.
*
- * @see #featurePolicy(String)
* @since 5.1
+ * @see #featurePolicy(String)
*/
public class FeaturePolicySpec {
@@ -3763,9 +3781,9 @@ public class ServerHttpSecurity {
/**
* Configures {@code Referrer-Policy} response header.
*
+ * @since 5.1
* @see #referrerPolicy()
* @see #referrerPolicy(ReferrerPolicy)
- * @since 5.1
*/
public class ReferrerPolicySpec {
diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java
index 0e779e9c4a..555ff3fd48 100644
--- a/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java
+++ b/config/src/test/java/org/springframework/security/config/annotation/web/SampleWebSecurityConfigurerAdapterTests.java
@@ -109,29 +109,29 @@ public class SampleWebSecurityConfigurerAdapterTests {
}
/**
- *
- *
- *
- *
- *
+ * <http>
+ * <intercept-url pattern="/resources/**" access="permitAll"/>
+ * <intercept-url pattern="/**" access="authenticated"/>
+ * <logout
* logout-success-url="/login?logout"
* logout-url="/logout"
- *
- * login-processing-url="/login"
+ * login-page="/login" <!-- Except Spring Security renders the login page -->
+ * login-processing-url="/login" <!-- but only POST -->
* password-parameter="password"
* username-parameter="username"
- * />
- *
- *
- *
- *
- *
- *
- *
- *
- *
+ * />
+ * </http>
+ * <authentication-manager>
+ * <authentication-provider>
+ * <user-service>
+ * <user username="user" password="password" authorities="ROLE_USER"/>
+ * </user-service>
+ * </authentication-provider>
+ * </authentication-manager>
+ *
*
* @author Rob Winch
*/
@@ -183,35 +183,35 @@ public class SampleWebSecurityConfigurerAdapterTests {
}
/**
- *
- *
- *
- *
- *
- *
- *
- *
- *
+ * <http security="none" pattern="/resources/**"/>
+ * <http>
+ * <intercept-url pattern="/logout" access="permitAll"/>
+ * <intercept-url pattern="/login" access="permitAll"/>
+ * <intercept-url pattern="/signup" access="permitAll"/>
+ * <intercept-url pattern="/about" access="permitAll"/>
+ * <intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>
+ * <logout
* logout-success-url="/login?logout"
* logout-url="/logout"
- *
+ * login-processing-url="/login" <!-- but only POST -->
* password-parameter="password"
* username-parameter="username"
- * />
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
+ * />
+ * </http>
+ * <authentication-manager>
+ * <authentication-provider>
+ * <user-service>
+ * <user username="user" password="password" authorities="ROLE_USER"/>
+ * <user username="admin" password="password" authorities=
+ "ROLE_USER,ROLE_ADMIN"/>
+ * </user-service>
+ * </authentication-provider>
+ * </authentication-manager>
+ *
*
* @author Rob Winch
*/
@@ -319,38 +319,38 @@ public class SampleWebSecurityConfigurerAdapterTests {
/**
*
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
+ * login-processing-url="/login" <!-- but only POST -->
* password-parameter="password"
* username-parameter="username"
- * />
- *
- *
- *
- *
- *
- *
- *
- *
- *
+ * />
+ * </http>
+ * <authentication-manager>
+ * <authentication-provider>
+ * <user-service>
+ * <user username="user" password="password" authorities="ROLE_USER"/>
+ * <user username="admin" password="password" authorities=
+ "ROLE_USER,ROLE_ADMIN"/>
+ * </user-service>
+ * </authentication-provider>
+ * </authentication-manager>
*
*
* @author Rob Winch
diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java
index ac5075b71c..556c3d1a49 100644
--- a/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java
+++ b/config/src/test/java/org/springframework/security/config/annotation/web/builders/NamespaceHttpTests.java
@@ -63,8 +63,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
- * Tests to verify that all the functionality of true if not anonymous, otherwise false.
*/
private boolean isNotAnonymous(Authentication authentication) {
- return !authTrustResolver.isAnonymous(authentication);
+ return !this.authTrustResolver.isAnonymous(authentication);
}
/**
diff --git a/core/src/main/java/org/springframework/security/authorization/AuthorityReactiveAuthorizationManager.java b/core/src/main/java/org/springframework/security/authorization/AuthorityReactiveAuthorizationManager.java
index 31d85ebfb1..a1a2a4784a 100644
--- a/core/src/main/java/org/springframework/security/authorization/AuthorityReactiveAuthorizationManager.java
+++ b/core/src/main/java/org/springframework/security/authorization/AuthorityReactiveAuthorizationManager.java
@@ -16,20 +16,21 @@
package org.springframework.security.authorization;
-import org.springframework.security.core.Authentication;
-import org.springframework.util.Assert;
-import reactor.core.publisher.Mono;
-
import java.util.Arrays;
import java.util.List;
+import reactor.core.publisher.Mono;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.util.Assert;
+
/**
* A {@link ReactiveAuthorizationManager} that determines if the current user is
* authorized by evaluating if the {@link Authentication} contains a specified authority.
*
+ * @param