Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: spring-projects/spring-security
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6.4.4
Choose a base ref
...
head repository: spring-projects/spring-security
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6.4.x
Choose a head ref

Commits on Feb 17, 2025

  1. Fix bug PublicKeyCredentialUserEntityRepository saves anonymousUser

    Issue gh-16385
    
    Signed-off-by: Borghi <137845283+Borghii@users.noreply.github.com>
    Borghii committed Feb 17, 2025
    Copy the full SHA
    0bc9313 View commit details

Commits on Mar 17, 2025

  1. Release 6.3.8

    github-actions[bot] committed Mar 17, 2025
    Copy the full SHA
    147081f View commit details
  2. Copy the full SHA
    816f3cd View commit details
  3. Copy the full SHA
    7dbd69f View commit details

Commits on Mar 18, 2025

  1. Bump org-eclipse-jetty from 11.0.24 to 11.0.25

    Bumps `org-eclipse-jetty` from 11.0.24 to 11.0.25.
    
    Updates `org.eclipse.jetty:jetty-server` from 11.0.24 to 11.0.25
    
    Updates `org.eclipse.jetty:jetty-servlet` from 11.0.24 to 11.0.25
    
    ---
    updated-dependencies:
    - dependency-name: org.eclipse.jetty:jetty-server
      dependency-type: direct:production
      update-type: version-update:semver-patch
    - dependency-name: org.eclipse.jetty:jetty-servlet
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and spring-builds committed Mar 18, 2025
    Copy the full SHA
    1d75b90 View commit details
  2. Bump org-eclipse-jetty from 11.0.24 to 11.0.25

    Bumps `org-eclipse-jetty` from 11.0.24 to 11.0.25.
    
    Updates `org.eclipse.jetty:jetty-server` from 11.0.24 to 11.0.25
    
    Updates `org.eclipse.jetty:jetty-servlet` from 11.0.24 to 11.0.25
    
    ---
    updated-dependencies:
    - dependency-name: org.eclipse.jetty:jetty-server
      dependency-type: direct:production
      update-type: version-update:semver-patch
    - dependency-name: org.eclipse.jetty:jetty-servlet
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and spring-builds committed Mar 18, 2025
    Copy the full SHA
    06893bc View commit details
  3. Correct Closing Tag

    Closes gh-16600
    
    Signed-off-by: AB <a.bierler@xdev-software.de>
    AB-xdev authored and jzheaux committed Mar 18, 2025
    Copy the full SHA
    d9a937f View commit details

Commits on Mar 19, 2025

  1. Bump ch.qos.logback:logback-classic from 1.5.17 to 1.5.18

    Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.5.17 to 1.5.18.
    - [Release notes](https://github.com/qos-ch/logback/releases)
    - [Commits](qos-ch/logback@v_1.5.17...v_1.5.18)
    
    ---
    updated-dependencies:
    - dependency-name: ch.qos.logback:logback-classic
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and spring-builds committed Mar 19, 2025
    Copy the full SHA
    60df37b View commit details
  2. Bump ch.qos.logback:logback-classic from 1.5.17 to 1.5.18

    Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.5.17 to 1.5.18.
    - [Release notes](https://github.com/qos-ch/logback/releases)
    - [Commits](qos-ch/logback@v_1.5.17...v_1.5.18)
    
    ---
    updated-dependencies:
    - dependency-name: ch.qos.logback:logback-classic
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and spring-builds committed Mar 19, 2025
    Copy the full SHA
    5353d49 View commit details

Commits on Mar 20, 2025

  1. Bump org.springframework:spring-framework-bom from 6.2.4 to 6.2.5

    Bumps [org.springframework:spring-framework-bom](https://github.com/spring-projects/spring-framework) from 6.2.4 to 6.2.5.
    - [Release notes](https://github.com/spring-projects/spring-framework/releases)
    - [Commits](spring-projects/spring-framework@v6.2.4...v6.2.5)
    
    ---
    updated-dependencies:
    - dependency-name: org.springframework:spring-framework-bom
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and spring-builds committed Mar 20, 2025
    Copy the full SHA
    68f08c2 View commit details
  2. Copy the full SHA
    85c9062 View commit details
  3. Update Gradle Wrapper Upgrade

    Issue gh-16221
    jzheaux committed Mar 20, 2025
    Copy the full SHA
    d1b7f8a View commit details
  4. Copy the full SHA
    55d6122 View commit details
  5. Fix WebFlux authentication reference link

    Closes gh-16702
    
    Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
    ngocnhan-tran1996 authored and sjohnr committed Mar 20, 2025
    Copy the full SHA
    75b537f View commit details
  6. Fix Spring Framework reference link

    Closes gh-16699
    
    Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
    ngocnhan-tran1996 authored and sjohnr committed Mar 20, 2025
    Copy the full SHA
    daf8cfe View commit details
  7. Fix typo

    Closes gh-16776
    
    Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
    ngocnhan-tran1996 authored and sjohnr committed Mar 20, 2025
    Copy the full SHA
    af40d7e View commit details
  8. Update ServerOAuth2AuthorizedClientExchangeFilterFunction javadoc

    Closes gh-16555
    
    Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
    ngocnhan-tran1996 authored and sjohnr committed Mar 20, 2025
    Copy the full SHA
    a53ca7c View commit details
  9. Clarify WebInvocationPrivilegeEvaluator JavaDoc

    Closes gh-16529
    
    Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
    ngocnhan-tran1996 authored and sjohnr committed Mar 20, 2025
    Copy the full SHA
    ab6e9d2 View commit details
  10. Merge branch '6.3.x' into 6.4.x

    Closes gh-16782
    Closes gh-16783
    Closes gh-16784
    Closes gh-16785
    Closes gh-16786
    sjohnr committed Mar 20, 2025
    Copy the full SHA
    96cfbd1 View commit details

Commits on Mar 21, 2025

  1. Add link to docs zip

    Closes gh-16798
    rwinch committed Mar 21, 2025
    Copy the full SHA
    65e83f8 View commit details
  2. Merge branch '6.3.x' into 6.4.x

    Closes gh-16799
    rwinch committed Mar 21, 2025
    Copy the full SHA
    af87861 View commit details
  3. Update authorize-http-requests.adoc

    Fix patterns in the Security Matchers documentation
    
    Signed-off-by: Bragolgirith <6455473+Bragolgirith@users.noreply.github.com>
    Bragolgirith authored and jzheaux committed Mar 21, 2025
    Copy the full SHA
    72554f7 View commit details
  4. Copy the full SHA
    db8b632 View commit details
  5. https docs download

    rwinch committed Mar 21, 2025
    Copy the full SHA
    58e7ba4 View commit details
  6. Copy the full SHA
    c032b20 View commit details

Commits on Mar 24, 2025

  1. Bump @springio/asciidoctor-extensions in /docs

    Bumps [@springio/asciidoctor-extensions](https://github.com/spring-io/asciidoctor-extensions) from 1.0.0-alpha.16 to 1.0.0-alpha.17.
    - [Changelog](https://github.com/spring-io/asciidoctor-extensions/blob/main/CHANGELOG.adoc)
    - [Commits](spring-io/asciidoctor-extensions@v1.0.0-alpha.16...v1.0.0-alpha.17)
    
    ---
    updated-dependencies:
    - dependency-name: "@springio/asciidoctor-extensions"
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and spring-builds committed Mar 24, 2025
    Copy the full SHA
    883765b View commit details
  2. Copy the full SHA
    23444dd View commit details
  3. Bump spring-io/spring-doc-actions from 0.0.18 to 0.0.19

    Bumps [spring-io/spring-doc-actions](https://github.com/spring-io/spring-doc-actions) from 0.0.18 to 0.0.19.
    - [Commits](spring-io/spring-doc-actions@852920b...c203826)
    
    ---
    updated-dependencies:
    - dependency-name: spring-io/spring-doc-actions
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and spring-builds committed Mar 24, 2025
    Copy the full SHA
    2f04512 View commit details
  4. Fix issues identified in PR review

    Signed-off-by: Borghi <137845283+Borghii@users.noreply.github.com>
    Borghii committed Mar 24, 2025
    Copy the full SHA
    e3a715b View commit details
  5. Fix issues identified in PR review

    Signed-off-by: Tomas Borghi <137845283+Borghii@users.noreply.github.com>
    Borghii authored Mar 24, 2025
    Copy the full SHA
    5571ad1 View commit details
  6. Delete import unused

    Signed-off-by: Tomas Borghi <137845283+Borghii@users.noreply.github.com>
    Borghii authored Mar 24, 2025
    Copy the full SHA
    0a08413 View commit details

Commits on Mar 25, 2025

  1. Bump Gradle Wrapper from 8.10.2 to 8.13.

    Release notes of Gradle 8.13 can be found here:
    https://docs.gradle.org/8.13/release-notes.html
    
    Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored and jzheaux committed Mar 25, 2025
    Copy the full SHA
    af2668f View commit details
  2. Copy the full SHA
    26aa253 View commit details
  3. Copy the full SHA
    4e20d56 View commit details
  4. Use !isAuthenticated

    It's more verbose to see if the user is not null and not anonymous
    
    Issue gh-16385
    rwinch committed Mar 25, 2025
    Copy the full SHA
    593f7c4 View commit details
  5. Use Test Name Conventions

    Issue gh-16385
    rwinch committed Mar 25, 2025
    Copy the full SHA
    9c05447 View commit details
  6. Additional WebAuthn4jRelyingPartyOperationTests

    - verify that anonymous users not saved
    - verify that when user found the CredentialRecord is allowed
    
    Issue gh-16385
    rwinch committed Mar 25, 2025
    Copy the full SHA
    a6b5c05 View commit details
  7. Copy the full SHA
    1f3dd53 View commit details

Commits on Mar 27, 2025

  1. Sort Advisors AfterSingletonsInstantiated

    In order to make so that authorization advisors are sorted
    only one time and also as part of the configuration lifecycle,
    AuthorizationAdvisorProxyFactory now implements
    SmartInitializingBean.
    
    Closes gh-16819
    
    Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
    ngocnhan-tran1996 authored and jzheaux committed Mar 27, 2025
    Copy the full SHA
    fcc1bd5 View commit details
  2. Add Test

    Issue gh-16819
    jzheaux committed Mar 27, 2025
    Copy the full SHA
    15b9a50 View commit details
  3. Sort Default Advisors and Added Advisors

    This commit ensures that the default advisors and added advisors
    are sorted in the event that this component is not being published
    as a Spring bean.
    
    Issue gh-16819
    jzheaux committed Mar 27, 2025
    Copy the full SHA
    456604a View commit details
  4. Merge branch '6.3.x' into 6.4.x

    Closes gh-16837
    jzheaux committed Mar 27, 2025
    Copy the full SHA
    6c5b6d1 View commit details
  5. Use correct message prompt

    Signed-off-by: DingHao <dh.hiekn@gmail.com>
    kse-music authored and jzheaux committed Mar 27, 2025
    Copy the full SHA
    1e7db09 View commit details
  6. Copy the full SHA
    1ad4323 View commit details

Commits on Mar 28, 2025

  1. Copy the full SHA
    c84c438 View commit details
  2. Copy the full SHA
    b7df861 View commit details
  3. Merge branch '6.3.x' into 6.4.x

    Closes gh-16844
    sjohnr committed Mar 28, 2025
    Copy the full SHA
    26c63ae View commit details
Showing with 211 additions and 50 deletions.
  1. +2 −2 .github/workflows/update-antora-ui-spring.yml
  2. +1 −1 build.gradle
  3. +3 −0 config/src/main/java/org/springframework/security/config/http/CsrfBeanDefinitionParser.java
  4. +17 −1 ...work/security/config/annotation/method/configuration/PrePostMethodSecurityConfigurationTests.java
  5. +37 −0 config/src/test/java/org/springframework/security/config/http/CsrfConfigTests.java
  6. +14 −7 ...main/java/org/springframework/security/authorization/method/AuthorizationAdvisorProxyFactory.java
  7. +2 −2 ...ava/org/springframework/security/authorization/method/AuthorizeReturnObjectMethodInterceptor.java
  8. +28 −1 ...c/test/java/org/springframework/security/authorization/AuthorizationAdvisorProxyFactoryTests.java
  9. +1 −1 docs/modules/ROOT/nav.adoc
  10. +1 −1 docs/modules/ROOT/pages/features/authentication/index.adoc
  11. +5 −0 docs/modules/ROOT/pages/index.adoc
  12. +3 −0 docs/modules/ROOT/pages/reactive/authentication/index.adoc
  13. +1 −1 docs/modules/ROOT/pages/servlet/appendix/namespace/http.adoc
  14. +12 −12 docs/modules/ROOT/pages/servlet/authorization/authorize-http-requests.adoc
  15. +1 −1 docs/modules/ROOT/pages/servlet/test/mockmvc/index.adoc
  16. +1 −1 gradle.properties
  17. +3 −3 gradle/libs.versions.toml
  18. BIN gradle/wrapper/gradle-wrapper.jar
  19. +2 −2 gradle/wrapper/gradle-wrapper.properties
  20. +2 −3 gradlew
  21. +2 −2 ...auth2/client/web/reactive/function/client/ServerOAuth2AuthorizedClientExchangeFilterFunction.java
  22. +11 −3 web/src/main/java/org/springframework/security/web/access/WebInvocationPrivilegeEvaluator.java
  23. +1 −1 ...ain/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java
  24. +13 −4 ...n/java/org/springframework/security/web/webauthn/management/Webauthn4JRelyingPartyOperations.java
  25. +48 −1 ...a/org/springframework/security/web/webauthn/management/Webauthn4jRelyingPartyOperationsTests.java
4 changes: 2 additions & 2 deletions .github/workflows/update-antora-ui-spring.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ jobs:
matrix:
branch: [ '5.8.x', '6.2.x', '6.3.x', 'main' ]
steps:
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@852920ba3fb1f28b35a2f13201133bc00ef33677
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@c2038265125ec6f305a4a041d892ee44c156a754
name: Update
with:
docs-branch: ${{ matrix.branch }}
@@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
name: Update on docs-build
steps:
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@852920ba3fb1f28b35a2f13201133bc00ef33677
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@c2038265125ec6f305a4a041d892ee44c156a754
name: Update
with:
docs-branch: 'docs-build'
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ wrapperUpgrade {
gradle {
'spring-security' {
repo = 'spring-projects/spring-security'
baseBranch = '6.2.x' // runs only on 6.2.x and the update is merged forward to main
baseBranch = '6.3.x' // runs only on 6.3.x and the update is merged forward to main
}
}
}
Original file line number Diff line number Diff line change
@@ -183,6 +183,9 @@ BeanDefinition getCsrfAuthenticationStrategy() {
BeanDefinitionBuilder csrfAuthenticationStrategy = BeanDefinitionBuilder
.rootBeanDefinition(CsrfAuthenticationStrategy.class);
csrfAuthenticationStrategy.addConstructorArgReference(this.csrfRepositoryRef);
if (StringUtils.hasText(this.requestHandlerRef)) {
csrfAuthenticationStrategy.addPropertyReference("requestHandler", this.requestHandlerRef);
}
return csrfAuthenticationStrategy.getBeanDefinition();
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -56,6 +56,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Role;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.AnnotationConfigurationException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.PermissionEvaluator;
@@ -1103,6 +1104,21 @@ public void jsr250MethodWhenExcludeAuthorizationObservationsThenUnobserved() {
verifyNoInteractions(handler);
}

// gh-16819
@Test
void autowireWhenDefaultsThenAdvisorAnnotationsAreSorted() {
this.spring.register(MethodSecurityServiceConfig.class).autowire();
AuthorizationAdvisorProxyFactory proxyFactory = this.spring.getContext()
.getBean(AuthorizationAdvisorProxyFactory.class);
AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE;
AuthorizationAdvisor previous = null;
for (AuthorizationAdvisor advisor : proxyFactory) {
boolean ordered = previous == null || comparator.compare(previous, advisor) < 0;
assertThat(ordered).isTrue();
previous = advisor;
}
}

private static Consumer<ConfigurableWebApplicationContext> disallowBeanOverriding() {
return (context) -> ((AnnotationConfigWebApplicationContext) context).setAllowBeanDefinitionOverriding(false);
}
Original file line number Diff line number Diff line change
@@ -336,6 +336,43 @@ public void postWhenUsingCsrfAndXorCsrfTokenRequestAttributeHandlerWithRawTokenT
// @formatter:on
}

@Test
public void postWhenUsingCsrfAndXorCsrfTokenRequestAttributeHandlerThenCsrfAuthenticationStrategyUses()
throws Exception {
this.spring.configLocations(this.xml("WithXorCsrfTokenRequestAttributeHandler"), this.xml("shared-controllers"))
.autowire();
// @formatter:off
MvcResult mvcResult1 = this.mvc.perform(get("/csrf"))
.andExpect(status().isOk())
.andReturn();
// @formatter:on
MockHttpServletRequest request1 = mvcResult1.getRequest();
MockHttpSession session = (MockHttpSession) request1.getSession();
CsrfTokenRepository repository = WebTestUtils.getCsrfTokenRepository(request1);
// @formatter:off
MockHttpServletRequestBuilder login = post("/login")
.param("username", "user")
.param("password", "password")
.session(session)
.with(csrf());
this.mvc.perform(login)
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("/"));
// @formatter:on
assertThat(repository.loadToken(request1)).isNull();
// @formatter:off
MvcResult mvcResult2 = this.mvc.perform(get("/csrf").session(session))
.andExpect(status().isOk())
.andReturn();
// @formatter:on
MockHttpServletRequest request2 = mvcResult2.getRequest();
CsrfToken csrfToken = repository.loadToken(request2);
CsrfToken csrfTokenAttribute = (CsrfToken) request2.getAttribute(CsrfToken.class.getName());
assertThat(csrfTokenAttribute).isNotNull();
assertThat(csrfTokenAttribute.getToken()).isNotBlank();
assertThat(csrfTokenAttribute.getToken()).isNotEqualTo(csrfToken.getToken());
}

@Test
public void postWhenHasCsrfTokenButSessionExpiresThenRequestIsCancelledAfterSuccessfulAuthentication()
throws Exception {
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -47,6 +47,7 @@
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.AopInfrastructureBean;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.lang.NonNull;
import org.springframework.security.authorization.AuthorizationProxyFactory;
@@ -79,8 +80,8 @@
* @author Josh Cummings
* @since 6.3
*/
public final class AuthorizationAdvisorProxyFactory
implements AuthorizationProxyFactory, Iterable<AuthorizationAdvisor>, AopInfrastructureBean {
public final class AuthorizationAdvisorProxyFactory implements AuthorizationProxyFactory,
Iterable<AuthorizationAdvisor>, AopInfrastructureBean, SmartInitializingSingleton {

private static final boolean isReactivePresent = ClassUtils.isPresent("reactor.core.publisher.Mono", null);

@@ -125,6 +126,7 @@ public static AuthorizationAdvisorProxyFactory withDefaults() {
advisors.add(new PostFilterAuthorizationMethodInterceptor());
AuthorizationAdvisorProxyFactory proxyFactory = new AuthorizationAdvisorProxyFactory(advisors);
proxyFactory.addAdvisor(new AuthorizeReturnObjectMethodInterceptor(proxyFactory));
AnnotationAwareOrderComparator.sort(proxyFactory.advisors);
return proxyFactory;
}

@@ -142,9 +144,15 @@ public static AuthorizationAdvisorProxyFactory withReactiveDefaults() {
advisors.add(new PostFilterAuthorizationReactiveMethodInterceptor());
AuthorizationAdvisorProxyFactory proxyFactory = new AuthorizationAdvisorProxyFactory(advisors);
proxyFactory.addAdvisor(new AuthorizeReturnObjectMethodInterceptor(proxyFactory));
AnnotationAwareOrderComparator.sort(proxyFactory.advisors);
return proxyFactory;
}

@Override
public void afterSingletonsInstantiated() {
AnnotationAwareOrderComparator.sort(this.advisors);
}

/**
* Proxy an object to enforce authorization advice.
*
@@ -165,7 +173,6 @@ public static AuthorizationAdvisorProxyFactory withReactiveDefaults() {
*/
@Override
public Object proxy(Object target) {
AnnotationAwareOrderComparator.sort(this.advisors);
if (target == null) {
return null;
}
@@ -178,9 +185,9 @@ public Object proxy(Object target) {
}
ProxyFactory factory = new ProxyFactory(target);
factory.addAdvisors(this.authorizationProxy);
for (Advisor advisor : this.advisors) {
factory.addAdvisors(advisor);
}
List<Advisor> advisors = new ArrayList<>(this.advisors);
AnnotationAwareOrderComparator.sort(advisors);
factory.addAdvisors(advisors);
factory.addInterface(AuthorizationProxy.class);
factory.setOpaque(true);
factory.setProxyTargetClass(!Modifier.isFinal(target.getClass().getModifiers()));
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -48,7 +48,7 @@ public final class AuthorizeReturnObjectMethodInterceptor implements Authorizati
private int order = AuthorizationInterceptorsOrder.SECURE_RESULT.getOrder();

public AuthorizeReturnObjectMethodInterceptor(AuthorizationProxyFactory authorizationProxyFactory) {
Assert.notNull(authorizationProxyFactory, "authorizationManager cannot be null");
Assert.notNull(authorizationProxyFactory, "authorizationProxyFactory cannot be null");
this.authorizationProxyFactory = authorizationProxyFactory;
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -40,6 +40,7 @@
import org.junit.jupiter.api.Test;

import org.springframework.aop.Pointcut;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.TestAuthentication;
@@ -360,6 +361,32 @@ public void proxyWhenDefaultsThenInstanceOfAuthorizationProxy() {
assertThat(target).isSameAs(this.flight);
}

// gh-16819
@Test
void advisorsWhenWithDefaultsThenAreSorted() {
AuthorizationAdvisorProxyFactory proxyFactory = AuthorizationAdvisorProxyFactory.withDefaults();
AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE;
AuthorizationAdvisor previous = null;
for (AuthorizationAdvisor advisor : proxyFactory) {
boolean ordered = previous == null || comparator.compare(previous, advisor) < 0;
assertThat(ordered).isTrue();
previous = advisor;
}
}

// gh-16819
@Test
void advisorsWhenWithReactiveDefaultsThenAreSorted() {
AuthorizationAdvisorProxyFactory proxyFactory = AuthorizationAdvisorProxyFactory.withReactiveDefaults();
AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE;
AuthorizationAdvisor previous = null;
for (AuthorizationAdvisor advisor : proxyFactory) {
boolean ordered = previous == null || comparator.compare(previous, advisor) < 0;
assertThat(ordered).isTrue();
previous = advisor;
}
}

private Authentication authenticated(String user, String... authorities) {
return TestAuthentication.authenticated(TestAuthentication.withUsername(user).authorities(authorities).build());
}
2 changes: 1 addition & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@
*** xref:servlet/appendix/faq.adoc[FAQ]
* xref:reactive/index.adoc[Reactive Applications]
** xref:reactive/getting-started.adoc[Getting Started]
** Authentication
** xref:reactive/authentication/index.adoc[Authentication]
*** xref:reactive/authentication/x509.adoc[X.509 Authentication]
*** xref:reactive/authentication/logout.adoc[Logout]
*** Session Management
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/features/authentication/index.adoc
Original file line number Diff line number Diff line change
@@ -8,4 +8,4 @@ Once authentication is performed we know the identity and can perform authorizat

Spring Security provides built-in support for authenticating users.
This section is dedicated to generic authentication support that applies in both Servlet and WebFlux environments.
Refer to the sections on authentication for xref:servlet/authentication/index.adoc#servlet-authentication[Servlet] and xref:servlet/authentication/index.adoc[WebFlux] for details on what is supported for each stack.
Refer to the sections on authentication for xref:servlet/authentication/index.adoc[Servlet] and xref:reactive/authentication/index.adoc[WebFlux] for details on what is supported for each stack.
5 changes: 5 additions & 0 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
= Spring Security

[NOTE]
====
Spring Security's documentation can be https://docs.spring.io/spring-security/reference/spring-security-docs.zip[downloaded] as a zip file.
====

Spring Security is a framework that provides xref:features/authentication/index.adoc[authentication], xref:features/authorization/index.adoc[authorization], and xref:features/exploits/index.adoc[protection against common attacks].
With first class support for securing both xref:servlet/index.adoc[imperative] and xref:reactive/index.adoc[reactive] applications, it is the de-facto standard for securing Spring-based applications.

3 changes: 3 additions & 0 deletions docs/modules/ROOT/pages/reactive/authentication/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[webflux-authentication]]
= Authentication
:page-section-summary-toc: 1
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ The attributes on the `<http>` element control some of the properties on the cor
Use AuthorizationManager API instead of SecurityMetadataSource (defaults to true)

[[nsa-http-authorization-manager-ref]]
* **access-decision-manager-ref**
* **use-authorization-manager**
Use this AuthorizationManager instead of deriving one from <intercept-url> elements

[[nsa-http-access-decision-manager-ref]]
Original file line number Diff line number Diff line change
@@ -1048,8 +1048,8 @@ public class SecurityConfig {
http
.securityMatcher("/api/**") <1>
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/user/**").hasRole("USER") <2>
.requestMatchers("/admin/**").hasRole("ADMIN") <3>
.requestMatchers("/api/user/**").hasRole("USER") <2>
.requestMatchers("/api/admin/**").hasRole("ADMIN") <3>
.anyRequest().authenticated() <4>
)
.formLogin(withDefaults());
@@ -1071,8 +1071,8 @@ open class SecurityConfig {
http {
securityMatcher("/api/**") <1>
authorizeHttpRequests {
authorize("/user/**", hasRole("USER")) <2>
authorize("/admin/**", hasRole("ADMIN")) <3>
authorize("/api/user/**", hasRole("USER")) <2>
authorize("/api/admin/**", hasRole("ADMIN")) <3>
authorize(anyRequest, authenticated) <4>
}
}
@@ -1084,8 +1084,8 @@ open class SecurityConfig {
======

<1> Configure `HttpSecurity` to only be applied to URLs that start with `/api/`
<2> Allow access to URLs that start with `/user/` to users with the `USER` role
<3> Allow access to URLs that start with `/admin/` to users with the `ADMIN` role
<2> Allow access to URLs that start with `/api/user/` to users with the `USER` role
<3> Allow access to URLs that start with `/api/admin/` to users with the `ADMIN` role
<4> Any other request that doesn't match the rules above, will require authentication

The `securityMatcher(s)` and `requestMatcher(s)` methods will decide which `RequestMatcher` implementation fits best for your application: If {spring-framework-reference-url}web.html#spring-web[Spring MVC] is in the classpath, then javadoc:org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher[] will be used, otherwise, javadoc:org.springframework.security.web.util.matcher.AntPathRequestMatcher[] will be used.
@@ -1111,8 +1111,8 @@ public class SecurityConfig {
http
.securityMatcher(antMatcher("/api/**")) <2>
.authorizeHttpRequests(authorize -> authorize
.requestMatchers(antMatcher("/user/**")).hasRole("USER") <3>
.requestMatchers(regexMatcher("/admin/.*")).hasRole("ADMIN") <4>
.requestMatchers(antMatcher("/api/user/**")).hasRole("USER") <3>
.requestMatchers(regexMatcher("/api/admin/.*")).hasRole("ADMIN") <4>
.requestMatchers(new MyCustomRequestMatcher()).hasRole("SUPERVISOR") <5>
.anyRequest().authenticated()
)
@@ -1146,8 +1146,8 @@ open class SecurityConfig {
http {
securityMatcher(antMatcher("/api/**")) <2>
authorizeHttpRequests {
authorize(antMatcher("/user/**"), hasRole("USER")) <3>
authorize(regexMatcher("/admin/**"), hasRole("ADMIN")) <4>
authorize(antMatcher("/api/user/**"), hasRole("USER")) <3>
authorize(regexMatcher("/api/admin/**"), hasRole("ADMIN")) <4>
authorize(MyCustomRequestMatcher(), hasRole("SUPERVISOR")) <5>
authorize(anyRequest, authenticated)
}
@@ -1161,8 +1161,8 @@ open class SecurityConfig {

<1> Import the static factory methods from `AntPathRequestMatcher` and `RegexRequestMatcher` to create `RequestMatcher` instances.
<2> Configure `HttpSecurity` to only be applied to URLs that start with `/api/`, using `AntPathRequestMatcher`
<3> Allow access to URLs that start with `/user/` to users with the `USER` role, using `AntPathRequestMatcher`
<4> Allow access to URLs that start with `/admin/` to users with the `ADMIN` role, using `RegexRequestMatcher`
<3> Allow access to URLs that start with `/api/user/` to users with the `USER` role, using `AntPathRequestMatcher`
<4> Allow access to URLs that start with `/api/admin/` to users with the `ADMIN` role, using `RegexRequestMatcher`
<5> Allow access to URLs that match the `MyCustomRequestMatcher` to users with the `SUPERVISOR` role, using a custom `RequestMatcher`

== Further Reading
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/servlet/test/mockmvc/index.adoc
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
= Spring MVC Test Integration
:page-section-summary-toc: 1

Spring Security provides comprehensive integration with https://docs.spring.io/spring/docs/current/spring-framework-reference/html/testing.html#spring-mvc-test-framework[Spring MVC Test]
Spring Security provides comprehensive integration with {spring-framework-reference-url}testing/mockmvc.html[Spring MVC Test]
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
# limitations under the License.
#
springBootVersion=3.3.3
version=6.4.4
version=6.4.5-SNAPSHOT
samplesBranch=main
org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError
org.gradle.parallel=true
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -8,16 +8,16 @@ org-apache-directory-server = "1.5.5"
org-apache-maven-resolver = "1.9.22"
org-aspectj = "1.9.22.1"
org-bouncycastle = "1.79"
org-eclipse-jetty = "11.0.24"
org-eclipse-jetty = "11.0.25"
org-jetbrains-kotlin = "1.9.25"
org-jetbrains-kotlinx = "1.9.0"
org-mockito = "5.14.2"
org-opensaml = "4.3.2"
org-opensaml5 = "5.1.2"
org-springframework = "6.2.4"
org-springframework = "6.2.5"

[libraries]
ch-qos-logback-logback-classic = "ch.qos.logback:logback-classic:1.5.17"
ch-qos-logback-logback-classic = "ch.qos.logback:logback-classic:1.5.18"
com-fasterxml-jackson-jackson-bom = "com.fasterxml.jackson:jackson-bom:2.18.3"
com-google-inject-guice = "com.google.inject:guice:3.0"
com-netflix-nebula-nebula-project-plugin = "com.netflix.nebula:nebula-project-plugin:8.2.0"
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading