Skip to content

Commit 16db74c

Browse files
authored
Merge branch 'spring-projects:main' into gh-16825
2 parents a75c0c6 + a283700 commit 16db74c

File tree

502 files changed

+25074
-2825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

502 files changed

+25074
-2825
lines changed

.github/dco.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require:
2+
members: false

.github/dependabot.yml

+40
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ registries:
44
type: maven-repository
55
url: https://repo.spring.io/milestone
66
updates:
7+
- package-ecosystem: gradle
8+
target-branch: 6.4.x
9+
directory: /
10+
schedule:
11+
interval: daily
12+
time: '03:00'
13+
timezone: Etc/UTC
14+
labels:
15+
- 'type: dependency-upgrade'
16+
registries:
17+
- spring-milestones
18+
ignore:
19+
- dependency-name: com.nimbusds:nimbus-jose-jwt
20+
- dependency-name: org.python:jython
21+
- dependency-name: org.apache.directory.server:*
22+
- dependency-name: org.apache.directory.shared:*
23+
- dependency-name: org.junit:junit-bom
24+
update-types:
25+
- version-update:semver-major
26+
- dependency-name: org.mockito:mockito-bom
27+
update-types:
28+
- version-update:semver-major
29+
- dependency-name: '*'
30+
update-types:
31+
- version-update:semver-major
32+
- version-update:semver-minor
733
- package-ecosystem: gradle
834
target-branch: 6.3.x
935
directory: /
@@ -19,6 +45,7 @@ updates:
1945
- dependency-name: com.nimbusds:nimbus-jose-jwt
2046
- dependency-name: org.python:jython
2147
- dependency-name: org.apache.directory.server:*
48+
- dependency-name: org.apache.directory.shared:*
2249
- dependency-name: org.junit:junit-bom
2350
update-types:
2451
- version-update:semver-major
@@ -44,6 +71,7 @@ updates:
4471
- dependency-name: com.nimbusds:nimbus-jose-jwt
4572
- dependency-name: org.python:jython
4673
- dependency-name: org.apache.directory.server:*
74+
- dependency-name: org.apache.directory.shared:*
4775
- dependency-name: org.junit:junit-bom
4876
update-types:
4977
- version-update:semver-major
@@ -58,6 +86,16 @@ updates:
5886
update-types:
5987
- version-update:semver-major
6088

89+
- package-ecosystem: github-actions
90+
target-branch: 6.4.x
91+
directory: /
92+
schedule:
93+
interval: weekly
94+
labels:
95+
- 'type: task'
96+
- 'in: build'
97+
ignore:
98+
- dependency-name: sjohnr/*
6199
- package-ecosystem: github-actions
62100
target-branch: 6.3.x
63101
directory: /
@@ -66,6 +104,8 @@ updates:
66104
labels:
67105
- 'type: task'
68106
- 'in: build'
107+
ignore:
108+
- dependency-name: sjohnr/*
69109
- package-ecosystem: github-actions
70110
target-branch: main
71111
directory: /

.github/workflows/gradle-wrapper-upgrade-execution.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
java-version: '17'
2626
distribution: 'temurin'
2727
- name: Set up Gradle
28-
uses: gradle/gradle-build-action@v3
28+
uses: gradle/gradle-build-action@v2
2929
- name: Upgrade Wrappers
3030
run: ./gradlew clean upgradeGradleWrapperAll --continue -Porg.gradle.java.installations.auto-download=false
3131
env:

.github/workflows/release-scheduler.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
# List of active maintenance branches.
14-
branch: [ main, 6.3.x, 6.2.x, 5.8.x ]
14+
branch: [ main, 6.4.x, 6.3.x ]
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout

CONTRIBUTING.adoc

+14-25
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ See https://github.com/spring-projects/spring-security/tree/main#building-from-s
7979

8080
The wiki pages https://github.com/spring-projects/spring-framework/wiki/Code-Style[Code Style] and https://github.com/spring-projects/spring-framework/wiki/IntelliJ-IDEA-Editor-Settings[IntelliJ IDEA Editor Settings] define the source file coding standards we use along with some IDEA editor settings we customize.
8181

82-
To format the code as well as check the style, run `./gradlew format check`.
82+
To format the code as well as check the style, run `./gradlew format && ./gradlew check`.
8383

8484
[[submit-a-pull-request]]
8585
=== Submit a Pull Request
@@ -89,41 +89,30 @@ We are excited for your pull request! :heart:
8989
Please do your best to follow these steps.
9090
Don't worry if you don't get them all correct the first time, we will help you.
9191

92-
[[sign-cla]]
93-
1. If you have not previously done so, please sign the https://cla.spring.io/sign/spring[Contributor License Agreement].
94-
You will be reminded automatically when you submit the PR.
95-
[[create-an-issue]]
96-
1. Must you https://github.com/spring-projects/spring-security/issues/new/choose[create an issue] first? No, but it is recommended for features and larger bug fixes. It's easier discuss with the team first to determine the right fix or enhancement.
92+
1. [[sign-cla]] All commits must include a __Signed-off-by__ trailer at the end of each commit message to indicate that the contributor agrees to the Developer Certificate of Origin.
93+
For additional details, please refer to the blog post https://spring.io/blog/2025/01/06/hello-dco-goodbye-cla-simplifying-contributions-to-spring[Hello DCO, Goodbye CLA: Simplifying Contributions to Spring].
94+
2. [[create-an-issue-list]] Must you https://github.com/spring-projects/spring-security/issues/new/choose[create an issue] first? No, but it is recommended for features and larger bug fixes. It's easier discuss with the team first to determine the right fix or enhancement.
9795
For typos and straightforward bug fixes, starting with a pull request is encouraged.
9896
Please include a description for context and motivation.
9997
Note that the team may close your pull request if it's not a fit for the project.
100-
[[choose-a-branch]]
101-
1. Always check out the branch indicated in the milestone and submit pull requests against it (for example, for milestone `5.8.3` use the `5.8.x` branch).
98+
3. [[choose-a-branch]] Always check out the branch indicated in the milestone and submit pull requests against it (for example, for milestone `5.8.3` use the `5.8.x` branch).
10299
If there is no milestone, choose `main`.
103100
Once merged, the fix will be forwarded-ported to applicable branches including `main`.
104-
[[create-a-local-branch]]
105-
1. Create a local branch
101+
4. [[create-a-local-branch]] Create a local branch
106102
If this is for an issue, consider a branch name with the issue number, like `gh-22276`.
107-
[[write-tests]]
108-
1. Add documentation and JUnit Tests for your changes.
109-
[[update-copyright]]
110-
1. In all files you edited, if the copyright header is of the form 2002-20xx, update the final copyright year to the current year.
111-
[[add-since]]
112-
1. If on `main`, add `@since` JavaDoc attributes to new public APIs that your PR adds
113-
[[change-rnc]]
114-
1. If you are updating the XSD, please instead update the RNC file and then run `./gradlew :spring-security-config:rncToXsd`.
115-
[[format-code]]
116-
1. For each commit, build the code using `./gradlew format check`.
103+
5. [[write-tests]] Add documentation and JUnit Tests for your changes.
104+
6. [[update-copyright]] In all files you edited, if the copyright header is of the form 2002-20xx, update the final copyright year to the current year.
105+
7. [[add-since]] If on `main`, add `@since` JavaDoc attributes to new public APIs that your PR adds
106+
8. [[change-rnc]] If you are updating the XSD, please instead update the RNC file and then run `./gradlew :spring-security-config:rncToXsd`.
107+
9. [[format-code]] For each commit, build the code using `./gradlew format && ./gradlew check`.
117108
This command ensures the code meets most of <<code-style,the style guide>>; a notable exception is import order.
118-
[[commit-atomically]]
119-
1. Choose the granularity of your commits consciously and squash commits that represent
109+
10. [[commit-atomically]] Choose the granularity of your commits consciously and squash commits that represent
120110
multiple edits or corrections of the same logical change.
121111
See https://git-scm.com/book/en/Git-Tools-Rewriting-History[Rewriting History section of Pro Git] for an overview of streamlining the commit history.
122-
[[format-commit-messages]]
123-
1. Format commit messages using 55 characters for the subject line, 72 characters per line
112+
11. [[format-commit-messages]] Format commit messages using 55 characters for the subject line, 72 characters per line
124113
for the description, followed by the issue fixed, for example, `Closes gh-22276`.
125114
See the https://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project#Commit-Guidelines[Commit Guidelines section of Pro Git] for best practices around commit messages, and use `git log` to see some examples.
126-
Present tense is preferred.
115+
Favor imperative tense over present tense (use "Fix" instead of "Fixes"); avoid past tense (use "Fix" instead of "Fixed").
127116
+
128117
[indent=0]
129118
----

acl/src/main/java/org/springframework/security/acls/AclEntryVoter.java

+4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@
9696
* All comparisons and prefixes are case sensitive.
9797
*
9898
* @author Ben Alex
99+
* @deprecated please use {@link AclPermissionEvaluator} instead. Spring Method Security
100+
* annotations may also prove useful, for example
101+
* {@code @PreAuthorize("hasPermission(#id, ObjectsReturnType.class, read)")}
99102
*/
103+
@Deprecated
100104
public class AclEntryVoter extends AbstractAclVoter {
101105

102106
private static final Log logger = LogFactory.getLog(AclEntryVoter.class);

acl/src/main/java/org/springframework/security/acls/afterinvocation/AbstractAclProvider.java

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.security.access.AfterInvocationProvider;
2222
import org.springframework.security.access.ConfigAttribute;
23+
import org.springframework.security.acls.AclPermissionEvaluator;
2324
import org.springframework.security.acls.domain.ObjectIdentityRetrievalStrategyImpl;
2425
import org.springframework.security.acls.domain.SidRetrievalStrategyImpl;
2526
import org.springframework.security.acls.model.Acl;
@@ -39,7 +40,11 @@
3940
* services.
4041
*
4142
* @author Ben Alex
43+
* @deprecated please use {@link AclPermissionEvaluator} instead. Spring Method Security
44+
* annotations may also prove useful, for example
45+
* {@code @PostAuthorize("hasPermission(filterObject, read)")}
4246
*/
47+
@Deprecated
4348
public abstract class AbstractAclProvider implements AfterInvocationProvider {
4449

4550
protected final AclService aclService;

acl/src/main/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProvider.java

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.security.access.AccessDeniedException;
2727
import org.springframework.security.access.AuthorizationServiceException;
2828
import org.springframework.security.access.ConfigAttribute;
29+
import org.springframework.security.acls.AclPermissionEvaluator;
2930
import org.springframework.security.acls.model.AclService;
3031
import org.springframework.security.acls.model.Permission;
3132
import org.springframework.security.core.Authentication;
@@ -62,7 +63,11 @@
6263
*
6364
* @author Ben Alex
6465
* @author Paulo Neves
66+
* @deprecated please use {@link AclPermissionEvaluator} instead. Spring Method Security
67+
* annotations may also prove useful, for example
68+
* {@code @PostFilter("hasPermission(filterObject, read)")}
6569
*/
70+
@Deprecated
6671
public class AclEntryAfterInvocationCollectionFilteringProvider extends AbstractAclProvider {
6772

6873
protected static final Log logger = LogFactory.getLog(AclEntryAfterInvocationCollectionFilteringProvider.class);

acl/src/main/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationProvider.java

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.context.support.MessageSourceAccessor;
2828
import org.springframework.security.access.AccessDeniedException;
2929
import org.springframework.security.access.ConfigAttribute;
30+
import org.springframework.security.acls.AclPermissionEvaluator;
3031
import org.springframework.security.acls.model.AclService;
3132
import org.springframework.security.acls.model.Permission;
3233
import org.springframework.security.core.Authentication;
@@ -59,7 +60,12 @@
5960
* granted and <code>null</code> will be returned.
6061
* <p>
6162
* All comparisons and prefixes are case sensitive.
63+
*
64+
* @deprecated please use {@link AclPermissionEvaluator} instead. Spring Method Security
65+
* annotations may also prove useful, for example
66+
* {@code @PostAuthorize("hasPermission(filterObject, read)")}
6267
*/
68+
@Deprecated
6369
public class AclEntryAfterInvocationProvider extends AbstractAclProvider implements MessageSourceAware {
6470

6571
protected static final Log logger = LogFactory.getLog(AclEntryAfterInvocationProvider.class);

acl/src/main/java/org/springframework/security/acls/afterinvocation/ArrayFilterer.java

+2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
*
3333
* @author Ben Alex
3434
* @author Paulo Neves
35+
* @deprecated please see {@code PostFilter}
3536
*/
37+
@Deprecated
3638
class ArrayFilterer<T> implements Filterer<T> {
3739

3840
protected static final Log logger = LogFactory.getLog(ArrayFilterer.class);

acl/src/main/java/org/springframework/security/acls/afterinvocation/CollectionFilterer.java

+2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
*
3232
* @author Ben Alex
3333
* @author Paulo Neves
34+
* @deprecated please see {@code PostFilter}
3435
*/
36+
@Deprecated
3537
class CollectionFilterer<T> implements Filterer<T> {
3638

3739
protected static final Log logger = LogFactory.getLog(CollectionFilterer.class);

acl/src/main/java/org/springframework/security/acls/afterinvocation/Filterer.java

+2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
*
2424
* @author Ben Alex
2525
* @author Paulo Neves
26+
* @deprecated please use {@code PreFilter} and {@code @PostFilter} instead
2627
*/
28+
@Deprecated
2729
interface Filterer<T> extends Iterable<T> {
2830

2931
/**

cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java

+15
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
5252
import org.springframework.security.web.savedrequest.RequestCache;
5353
import org.springframework.security.web.savedrequest.SavedRequest;
54+
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
5455
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
5556
import org.springframework.security.web.util.matcher.RequestMatcher;
5657
import org.springframework.util.Assert;
@@ -215,6 +216,8 @@ public class CasAuthenticationFilter extends AbstractAuthenticationProcessingFil
215216

216217
public CasAuthenticationFilter() {
217218
super("/login/cas");
219+
RequestMatcher processUri = PathPatternRequestMatcher.withDefaults().matcher("/login/cas");
220+
setRequiresAuthenticationRequestMatcher(processUri);
218221
setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler());
219222
setSecurityContextRepository(this.securityContextRepository);
220223
}
@@ -319,6 +322,18 @@ public final void setAuthenticationFailureHandler(AuthenticationFailureHandler f
319322
super.setAuthenticationFailureHandler(new CasAuthenticationFailureHandler(failureHandler));
320323
}
321324

325+
/**
326+
* Use this {@code RequestMatcher} to match proxy receptor requests. Without setting
327+
* this matcher, {@link CasAuthenticationFilter} will not capture any proxy receptor
328+
* requets.
329+
* @param proxyReceptorMatcher the {@link RequestMatcher} to use
330+
* @since 6.5
331+
*/
332+
public final void setProxyReceptorMatcher(RequestMatcher proxyReceptorMatcher) {
333+
Assert.notNull(proxyReceptorMatcher, "proxyReceptorMatcher cannot be null");
334+
this.proxyReceptorMatcher = proxyReceptorMatcher;
335+
}
336+
322337
public final void setProxyReceptorUrl(final String proxyReceptorUrl) {
323338
this.proxyReceptorMatcher = new AntPathRequestMatcher("/**" + proxyReceptorUrl);
324339
}

cas/src/test/java/org/springframework/security/cas/web/CasAuthenticationFilterTests.java

+22-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
4444
import org.springframework.security.web.context.SecurityContextRepository;
4545
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
46+
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
4647
import org.springframework.test.util.ReflectionTestUtils;
4748

4849
import static org.assertj.core.api.Assertions.assertThat;
@@ -78,7 +79,7 @@ public void testGettersSetters() {
7879

7980
@Test
8081
public void testNormalOperation() throws Exception {
81-
MockHttpServletRequest request = new MockHttpServletRequest();
82+
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/login/cas");
8283
request.setServletPath("/login/cas");
8384
request.addParameter("ticket", "ST-0-ER94xMJmn6pha35CQRoZ");
8485
CasAuthenticationFilter filter = new CasAuthenticationFilter();
@@ -103,7 +104,7 @@ public void testRequiresAuthenticationFilterProcessUrl() {
103104
String url = "/login/cas";
104105
CasAuthenticationFilter filter = new CasAuthenticationFilter();
105106
filter.setFilterProcessesUrl(url);
106-
MockHttpServletRequest request = new MockHttpServletRequest();
107+
MockHttpServletRequest request = new MockHttpServletRequest("POST", url);
107108
MockHttpServletResponse response = new MockHttpServletResponse();
108109
request.setServletPath(url);
109110
assertThat(filter.requiresAuthentication(request, response)).isTrue();
@@ -132,10 +133,11 @@ public void testRequiresAuthenticationAuthAll() {
132133
CasAuthenticationFilter filter = new CasAuthenticationFilter();
133134
filter.setFilterProcessesUrl(url);
134135
filter.setServiceProperties(properties);
135-
MockHttpServletRequest request = new MockHttpServletRequest();
136+
MockHttpServletRequest request = new MockHttpServletRequest("POST", url);
136137
MockHttpServletResponse response = new MockHttpServletResponse();
137138
request.setServletPath(url);
138139
assertThat(filter.requiresAuthentication(request, response)).isTrue();
140+
request = new MockHttpServletRequest("POST", "/other");
139141
request.setServletPath("/other");
140142
assertThat(filter.requiresAuthentication(request, response)).isFalse();
141143
request.setParameter(properties.getArtifactParameter(), "value");
@@ -170,7 +172,7 @@ public void testDoFilterAuthenticateAll() throws Exception {
170172
given(manager.authenticate(any(Authentication.class))).willReturn(authentication);
171173
ServiceProperties serviceProperties = new ServiceProperties();
172174
serviceProperties.setAuthenticateAllArtifacts(true);
173-
MockHttpServletRequest request = new MockHttpServletRequest();
175+
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/authenticate");
174176
request.setParameter("ticket", "ST-1-123");
175177
request.setServletPath("/authenticate");
176178
MockHttpServletResponse response = new MockHttpServletResponse();
@@ -266,4 +268,20 @@ void successfulAuthenticationWhenSecurityContextHolderStrategySetThenUses() thro
266268
verify(securityContextRepository).setContext(any(SecurityContext.class));
267269
}
268270

271+
@Test
272+
public void requiresAuthenticationWhenProxyRequestMatcherThenMatches() {
273+
CasAuthenticationFilter filter = new CasAuthenticationFilter();
274+
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/pgtCallback");
275+
MockHttpServletResponse response = new MockHttpServletResponse();
276+
request.setServletPath("/pgtCallback");
277+
assertThat(filter.requiresAuthentication(request, response)).isFalse();
278+
filter.setProxyReceptorMatcher(PathPatternRequestMatcher.withDefaults().matcher(request.getServletPath()));
279+
assertThat(filter.requiresAuthentication(request, response)).isFalse();
280+
filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
281+
assertThat(filter.requiresAuthentication(request, response)).isTrue();
282+
request.setRequestURI("/other");
283+
request.setServletPath("/other");
284+
assertThat(filter.requiresAuthentication(request, response)).isFalse();
285+
}
286+
269287
}

config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public BeanDefinition parse(Element element, ParserContext pc) {
9696
pc.getReaderContext()
9797
.fatal("You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or "
9898
+ "spring-security-3.1.xsd schema or spring-security-3.2.xsd schema or spring-security-4.0.xsd schema "
99-
+ "with Spring Security 6.4. Please update your schema declarations to the 6.4 schema.",
99+
+ "with Spring Security 6.5. Please update your schema declarations to the 6.5 schema.",
100100
element);
101101
}
102102
String name = pc.getDelegate().getLocalName(element);
@@ -221,7 +221,7 @@ private boolean namespaceMatchesVersion(Element element) {
221221

222222
private boolean matchesVersionInternal(Element element) {
223223
String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
224-
return schemaLocation.matches("(?m).*spring-security-6\\.4.*.xsd.*")
224+
return schemaLocation.matches("(?m).*spring-security-6\\.5.*.xsd.*")
225225
|| schemaLocation.matches("(?m).*spring-security.xsd.*")
226226
|| !schemaLocation.matches("(?m).*spring-security.*");
227227
}

0 commit comments

Comments
 (0)