1
0
mirror of synced 2026-08-31 22:46:02 +00:00

Compare commits

...

54 Commits

Author SHA1 Message Date
Josh Cummings 43f5ae5b21 Remove Auto-merge for .x Branches
Closes gh-19632

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-31 10:43:16 -06:00
Josh Cummings b2a6bbf314 Merge branch '7.1.x' 2026-08-31 10:42:04 -06:00
Joe Grandja 36aa2ad744 Merge branch '7.1.x' 2026-08-31 12:02:21 -04:00
Josh Cummings ed4e0e2ea8 Merge branch '7.1.x' 2026-08-31 09:55:00 -06:00
Josh Cummings 61feae94a0 Merge branch '7.1.x' 2026-08-26 10:17:45 -06:00
Josh Cummings d449950b36 Merge branch '7.1.x'
Closes gh-19573
2026-08-20 16:58:15 -06:00
Josh Cummings 19afc9121e Merge branch '7.1.x'
Closes gh-19568
# Conflicts:
#	gradle/libs.versions.toml
2026-08-20 12:29:12 -06:00
Josh Cummings 1fe59232f0 Update to Spring Data 2026.1.0-M1
Closes gh-19531

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:10 -06:00
Josh Cummings 8f13ab216f Update to Micrometer 1.18.0-M1
Closes gh-19530

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:09 -06:00
Josh Cummings 8beb08974b Update to Reactor 2026.0.0-M1
Closes gh-19529

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:09 -06:00
Josh Cummings 49c89546c6 Update to Spring Framework 7.1.0-M1
Closes gh-19528

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:09 -06:00
Josh Cummings 5a74026036 Use jspecify Nullable in DPoPProofReplayValidator
org.springframework.lang.Nullable is banned by the
bannedNullabilityImports checkstyle rule on this line; the embargoed
commit that introduced this file predates that rule's adoption here.
Switch to org.jspecify.annotations.Nullable to match the rest of the
codebase (already used correctly elsewhere in this same file).

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:09 -06:00
Josh Cummings c9220ca39e Align Null Behavior
Previously, ExternalInetAddressMatcher treated a null InetAddress
as external by negating InternalInetAddressMatcher's result.

This commit makes ExternalInetAddressMatcher return false for a
null address, so that neither the internal nor the external
matcher classifies an unknown address as a match.

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:09 -06:00
Josh Cummings b6b9d743a0 Deprecate AesBytesEncryptor
This commit separates AesBytesEncryptor into two separate
implememtations, allowing for a migration away from default
arrangements that used a null IV

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:08 -06:00
Josh Cummings 8ded9dac6a Improve Equivalence Tests
This commit adds equals and hashCode implementations as well
as a readResolve implementation to ensure that deserialization
mechanisms can correctly assess the equality of a constnat
and a corresponding deserialized instance. For defense-in-depth
reasons, this commit also favors .equals over == for these
constants.

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:08 -06:00
Joe Grandja 1b84c74776 Bind UnboundIdContainer to loopback address 2026-08-20 10:38:08 -06:00
Joe Grandja 83dfc0790e Apply html encoding in DefaultConsentPage 2026-08-20 10:38:08 -06:00
Joe Grandja b55f66695e Provide ability to configure DPoP proof replay 2026-08-20 10:38:08 -06:00
Josh Cummings 177e482783 Use Constant-Time Comparison
This commit updates password encoders to use a
constant-time comparison method to defend against
timing attacks

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:07 -06:00
Josh Cummings 04d95818e3 Use Utf8#isEqual
Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:07 -06:00
Josh Cummings 627a412748 Use Constant-Time Equals
This commit updates the filter to use constant-time
equals for sensitive material

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:07 -06:00
Josh Cummings addebb61ed Use Constant-Time Equals
This commit updates the filter to use constant-time
equals for sensitive material

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:07 -06:00
Josh Cummings 75d985fb13 Add Utf8#isEqual
This commit adds a constant-time equals method,
useful for comparing password hashes or other
sensitive material

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:07 -06:00
Josh Cummings 342b24d43e Use MessageDigest#isEqual
This commit favors constant-time comparison
to mitigate timing attacks

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:07 -06:00
Josh Cummings 2f97d8dac2 Add Tests for User and Device Code
Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-20 10:38:06 -06:00
dependabot[bot] 3881de5d6c Bump com.fasterxml.jackson:jackson-bom from 2.22.1 to 2.22.2
Bumps [com.fasterxml.jackson:jackson-bom](https://github.com/FasterXML/jackson-bom) from 2.22.1 to 2.22.2.
- [Commits](https://github.com/FasterXML/jackson-bom/compare/jackson-bom-2.22.1...jackson-bom-2.22.2)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson:jackson-bom
  dependency-version: 2.22.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-20 03:17:09 +00:00
Josh Cummings 1fa37a9479 Merge branch '7.1.x' 2026-08-19 16:55:49 -06:00
Josh Cummings d7ea83017a Make MockSecurityContextHolderStrategy Thread-safe
Closes gh-19547

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-19 16:54:12 -06:00
Joe Grandja 6401fde9f2 Merge branch '7.1.x' 2026-08-18 12:17:53 -04:00
dependabot[bot] b622028f84 Bump tools.jackson:jackson-bom from 3.2.1 to 3.2.2
Bumps [tools.jackson:jackson-bom](https://github.com/FasterXML/jackson-bom) from 3.2.1 to 3.2.2.
- [Commits](https://github.com/FasterXML/jackson-bom/compare/jackson-bom-3.2.1...jackson-bom-3.2.2)

---
updated-dependencies:
- dependency-name: tools.jackson:jackson-bom
  dependency-version: 3.2.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-18 03:16:54 +00:00
dependabot[bot] 8b92e71cb2 Bump ch.qos.logback:logback-classic from 1.6.2 to 1.6.3
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.6.2 to 1.6.3.
- [Release notes](https://github.com/qos-ch/logback/releases)
- [Commits](https://github.com/qos-ch/logback/compare/v_1.6.2...v_1.6.3)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-version: 1.6.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-18 03:16:27 +00:00
dependabot[bot] 6ed154527e Bump ch.qos.logback:logback-classic from 1.6.1 to 1.6.2
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.6.1 to 1.6.2.
- [Release notes](https://github.com/qos-ch/logback/releases)
- [Commits](https://github.com/qos-ch/logback/compare/v_1.6.1...v_1.6.2)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-version: 1.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-17 03:18:43 +00:00
Josh Cummings 82241b6cb8 Merge branch '7.1.x'
Closes gh-19549
2026-08-13 15:59:03 -06:00
Josh Cummings 6eb16dc35e Merge branch '7.1.x'
Closes gh-19546
2026-08-13 15:20:47 -06:00
Josh Cummings 1ad93f45f8 Add Test Coverage for Implicit CORS Bean Detection
Verify that <cors> detects a PreFlightRequestHandler bean and uses a
PreFlightRequestFilter when no explicit ref or
configuration-source-ref is given and no mvcHandlerMappingIntrospector
bean is present.

See gh-19542

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-13 13:25:09 -06:00
Josh Cummings 8c9a8e3f6c Suppress Removal Warnings on RestOperations Usage
Spring Framework 7.1 deprecates RestTemplate and related types for
removal. Suppress the resulting warnings at existing internal usage
sites until they are migrated to RestClient per gh-19027.

Closes gh-19544

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-13 11:59:50 -06:00
Josh Cummings a8f54db7e4 Disable CORS Tests Relying on HandlerMappingIntrospector
Spring Framework 7.1 removes HandlerMappingIntrospector-derived
implicit CORS handling for plain requests; these tests assert the
old behavior.

Closes gh-19543

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-13 11:54:26 -06:00
Josh Cummings 24bfdc1dee Support Implicit CORS Bean Detection in <cors> Namespace
Add CorsFilterFactoryBean so the <cors> XML element can detect a
CorsConfigurationSource or PreFlightRequestHandler bean implicitly,
matching CorsConfigurer's existing Java config behavior.

Closes gh-19542

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-13 11:53:36 -06:00
Josh Cummings 8876c30b00 Disable Lowercase HTTP Method Firewall Test
Spring Framework's HttpMethod#valueOf now normalizes casing, so
StrictServerWebExchangeFirewall no longer detects a non-canonical-case
HTTP method as distinct from its canonical form.

Closes gh-19541

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-13 11:51:30 -06:00
Josh Cummings 94d36e603b Merge branch '7.1.x'
Closes gh-19540
2026-08-13 11:37:03 -06:00
dependabot[bot] 329e9e6d71 Bump org.apache.httpcomponents.client5:httpclient5 from 5.6.3 to 5.6.4
Bumps [org.apache.httpcomponents.client5:httpclient5](https://github.com/apache/httpcomponents-client) from 5.6.3 to 5.6.4.
- [Changelog](https://github.com/apache/httpcomponents-client/blob/rel/v5.6.4/RELEASE_NOTES.txt)
- [Commits](https://github.com/apache/httpcomponents-client/compare/rel/v5.6.3...rel/v5.6.4)

---
updated-dependencies:
- dependency-name: org.apache.httpcomponents.client5:httpclient5
  dependency-version: 5.6.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-13 03:18:39 +00:00
Josh Cummings 09a3280442 Merge branch '7.1.x' 2026-08-11 19:41:02 -06:00
Josh Cummings 88aedba0bf Update What's New
Issue gh-17655

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-11 16:30:43 -06:00
Josh Cummings f95a956345 Merge branch '7.1.x' 2026-08-11 16:20:05 -06:00
Josh Cummings 30cc0f21a9 Fix Documentation Sample Structure
Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-11 15:18:49 -07:00
Josh Cummings c096e45242 Support Account Status Checks in OneTimeTokenReactiveAuthenticationManager
Add the same opt-in UserDetailsChecker support to
OneTimeTokenReactiveAuthenticationManager, mirroring
OneTimeTokenAuthenticationProvider for the reactive stack.

Issue gh-17655

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-11 15:18:49 -07:00
Josh Cummings b3e262187c Make OneTimeTokenAuthenticationProvider Account Status Checks Opt-In
OneTimeTokenAuthenticationProvider no longer validates account status
by default. Applications can opt in via setUserDetailsChecker, for
example by providing AccountStatusUserDetailsChecker to reject locked,
disabled, or expired accounts.

Issue gh-17655

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-11 15:18:49 -07:00
Andrey Litvitski 64fa98da1a Validate account status in OneTimeTokenAuthenticationProvider
The main problem is that OneTimeTokenAuthenticationProvider does not
extend from AbstractUserDetailsAuthenticationProvider, which has a
preauthentication check for user details. However, we do not need to
extend from it because it does not fit the context of the class. In this
regard, I decided to add my own checker to this commit, which performs a
preauthentication check before authorizing the account, similar to how
it is done in AbstractUserDetailsAuthenticationProvider. I also added a
test to OneTimeTokenAuthenticationProviderTests that identifies this
problem.

Closes gh-17655

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
2026-08-11 15:18:49 -07:00
Josh Cummings 26b20b2dd2 Merge branch '7.1.x' 2026-08-11 14:00:54 -06:00
dependabot[bot] e4d43fb89a Bump com.nimbusds:oauth2-oidc-sdk from 11.38.1 to 11.38.2
Bumps [com.nimbusds:oauth2-oidc-sdk](https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) from 11.38.1 to 11.38.2 and com.nimbusds:nimbus-jose-jwt from 10.9 to 10.9.1, which oauth2-oidc-sdk 11.38.2 requires.
- [Changelog](https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/src/master/CHANGELOG.txt)
- [Commits](https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/branches/compare/11.38.2..11.38.1)

---
updated-dependencies:
- dependency-name: com.nimbusds:oauth2-oidc-sdk
  dependency-version: 11.38.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.nimbusds:nimbus-jose-jwt
  dependency-version: 10.9.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-11 17:59:52 +00:00
Josh Cummings 04c08bb42a Merge branch '7.1.x' 2026-08-11 11:09:29 -06:00
Josh Cummings 73c93cebaf Remove 6.5.x from Dependabot
Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
2026-08-11 10:25:22 -06:00
Josh Cummings 3c6df7df1f Update to 7.2.0-SNAPSHOT 2026-08-11 10:25:22 -06:00
dependabot[bot] 70b161c772 Bump org.junit:junit-bom from 6.1.2 to 6.1.3
Bumps [org.junit:junit-bom](https://github.com/junit-team/junit-framework) from 6.1.2 to 6.1.3.
- [Release notes](https://github.com/junit-team/junit-framework/releases)
- [Commits](https://github.com/junit-team/junit-framework/compare/r6.1.2...r6.1.3)

---
updated-dependencies:
- dependency-name: org.junit:junit-bom
  dependency-version: 6.1.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-11 03:24:26 +00:00
275 changed files with 5989 additions and 89 deletions
+51 -46
View File
@@ -4,52 +4,6 @@ registries:
type: maven-repository
url: https://build.shibboleth.net/maven/releases
updates:
# 6.5.x
- package-ecosystem: gradle
target-branch: 6.5.x
directory: /
schedule:
interval: daily
time: '03:00'
timezone: Etc/UTC
labels:
- 'type: dependency-upgrade'
- 'in: build'
registries:
- shibboleth
ignore:
- dependency-name: com.nimbusds:nimbus-jose-jwt
- dependency-name: org.python:jython
- dependency-name: org.apache.directory.server:*
- dependency-name: org.apache.directory.shared:*
- dependency-name: org.junit:junit-bom
update-types:
- version-update:semver-major
- dependency-name: org.mockito:mockito-bom
update-types:
- version-update:semver-major
- dependency-name: '*'
update-types:
- version-update:semver-major
- version-update:semver-minor
- package-ecosystem: npm
target-branch: 6.5.x
directory: /docs
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
- package-ecosystem: github-actions
target-branch: 6.5.x
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
# 7.0.x
- package-ecosystem: gradle
@@ -103,6 +57,57 @@ updates:
- 'type: dependency-upgrade'
- 'in: build'
# 7.1.x
- package-ecosystem: gradle
target-branch: 7.1.x
directory: /
schedule:
interval: daily
time: '03:00'
timezone: Etc/UTC
labels:
- 'type: dependency-upgrade'
- 'in: build'
registries:
- shibboleth
ignore:
- dependency-name: com.nimbusds:nimbus-jose-jwt
- dependency-name: org.python:jython
- dependency-name: org.apache.directory.server:*
- dependency-name: org.apache.directory.shared:*
- dependency-name: org.junit:junit-bom
update-types:
- version-update:semver-major
- dependency-name: org.mockito:mockito-bom
update-types:
- version-update:semver-major
- dependency-name: com.gradle.enterprise
update-types:
- version-update:semver-major
- version-update:semver-minor
- dependency-name: '*'
update-types:
- version-update:semver-major
- version-update:semver-minor
- package-ecosystem: npm
target-branch: 7.1.x
directory: /docs
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
- package-ecosystem: github-actions
target-branch: 7.1.x
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
# main
- package-ecosystem: gradle
target-branch: main
@@ -0,0 +1,16 @@
name: Merge Dependabot PR
on:
pull_request:
branches:
- main
- 'docs-build'
run-name: Merge Dependabot PR ${{ github.ref_name }}
jobs:
merge-dependabot-pr:
permissions: write-all
uses: spring-io/spring-github-workflows/.github/workflows/spring-merge-dependabot-pr.yml@0d3f15bb384839966a1ff5c4383731a2b747f24b # v7
with:
mergeArguments: --auto --rebase
@@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
branch: [ '6.5.x', '7.0.x', 'main' ]
branch: [ '6.5.x', '7.0.x', '7.1.x', 'main' ]
steps:
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@415e2b11a766ba64799fffb5c97a4f7e17f677cf # v0.0.22
name: Update
@@ -94,7 +94,7 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
public BeanDefinition parse(Element element, ParserContext pc) {
if (!namespaceMatchesVersion(element)) {
pc.getReaderContext()
.fatal("You cannot use any XSD older than spring-security-7.1.xsd. Either change to spring-security.xsd or spring-security-7.1.xsd",
.fatal("You cannot use any XSD older than spring-security-7.2.xsd. Either change to spring-security.xsd or spring-security-7.2.xsd",
element);
}
String name = pc.getDelegate().getLocalName(element);
@@ -219,7 +219,7 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
private boolean matchesVersionInternal(Element element) {
String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
return schemaLocation.matches("(?m).*spring-security-7\\.1.*.xsd.*")
return schemaLocation.matches("(?m).*spring-security-7\\.2.*.xsd.*")
|| schemaLocation.matches("(?m).*spring-security.xsd.*")
|| !schemaLocation.matches("(?m).*spring-security.*");
}
@@ -63,6 +63,7 @@ public final class OidcBackChannelLogoutHandler implements LogoutHandler {
private final OidcSessionRegistry sessionRegistry;
@SuppressWarnings("removal")
private RestOperations restOperations = new RestTemplate();
private String logoutUri = "{baseUrl}/logout/connect/back-channel/{registrationId}";
@@ -47,6 +47,10 @@ public class CorsBeanDefinitionParser {
if (StringUtils.hasText(filterRef)) {
return new RuntimeBeanReference(filterRef);
}
String configurationSourceRef = element.getAttribute(ATT_SOURCE);
if (!StringUtils.hasText(configurationSourceRef)) {
return new RootBeanDefinition(CorsFilterFactoryBean.class);
}
BeanMetadataElement configurationSource = getSource(element, parserContext);
if (configurationSource == null) {
throw new BeanCreationException("Could not create CorsFilter");
@@ -0,0 +1,68 @@
/*
* Copyright 2004-present 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.security.config.http;
import jakarta.servlet.Filter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.Nullable;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.PreFlightRequestHandler;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.filter.PreFlightRequestFilter;
class CorsFilterFactoryBean implements FactoryBean<Filter>, ApplicationContextAware {
private static final String HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME = "mvcHandlerMappingIntrospector";
private ApplicationContext context;
@Override
public Filter getObject() {
if (this.context.containsBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)) {
CorsConfigurationSource source = this.context.getBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME,
CorsConfigurationSource.class);
return new CorsFilter(source);
}
String[] preFlightRequestHandlerNames = this.context.getBeanNamesForType(PreFlightRequestHandler.class);
if (preFlightRequestHandlerNames.length == 1) {
PreFlightRequestHandler handler = this.context.getBean(PreFlightRequestHandler.class);
return new PreFlightRequestFilter(handler);
}
throw new NoSuchBeanDefinitionException(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME,
"A Bean named " + HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME + " of type "
+ CorsConfigurationSource.class.getName()
+ " is required to use <cors>. Please ensure Spring Security & Spring "
+ "MVC are configured in a shared ApplicationContext.");
}
@Nullable
@Override
public Class<?> getObjectType() {
return Filter.class;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = applicationContext;
}
}
@@ -14,9 +14,9 @@
# limitations under the License.
#
http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-7.1.xsd
http\://www.springframework.org/schema/security/spring-security-7.0.xsd=org/springframework/security/config/spring-security-7.1.xsd
http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-7.0.xsd
http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-7.2.xsd
http\://www.springframework.org/schema/security/spring-security-7.2.xsd=org/springframework/security/config/spring-security-7.2.xsd
http\://www.springframework.org/schema/security/spring-security-7.1.xsd=org/springframework/security/config/spring-security-7.1.xsd
http\://www.springframework.org/schema/security/spring-security-7.0.xsd=org/springframework/security/config/spring-security-7.0.xsd
http\://www.springframework.org/schema/security/spring-security-6.5.xsd=org/springframework/security/config/spring-security-6.5.xsd
http\://www.springframework.org/schema/security/spring-security-6.4.xsd=org/springframework/security/config/spring-security-6.4.xsd
@@ -44,7 +44,8 @@ http\://www.springframework.org/schema/security/spring-security-2.0.xsd=org/spri
http\://www.springframework.org/schema/security/spring-security-2.0.1.xsd=org/springframework/security/config/spring-security-2.0.1.xsd
http\://www.springframework.org/schema/security/spring-security-2.0.2.xsd=org/springframework/security/config/spring-security-2.0.2.xsd
http\://www.springframework.org/schema/security/spring-security-2.0.4.xsd=org/springframework/security/config/spring-security-2.0.4.xsd
https\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-7.1.xsd
https\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-7.2.xsd
https\://www.springframework.org/schema/security/spring-security-7.2.xsd=org/springframework/security/config/spring-security-7.2.xsd
https\://www.springframework.org/schema/security/spring-security-7.1.xsd=org/springframework/security/config/spring-security-7.1.xsd
https\://www.springframework.org/schema/security/spring-security-7.0.xsd=org/springframework/security/config/spring-security-7.0.xsd
https\://www.springframework.org/schema/security/spring-security-6.5.xsd=org/springframework/security/config/spring-security-6.5.xsd
@@ -25,12 +25,12 @@ public class MockSecurityContextHolderStrategy implements SecurityContextHolderS
private SecurityContext context;
@Override
public void clearContext() {
public synchronized void clearContext() {
this.context = null;
}
@Override
public SecurityContext getContext() {
public synchronized SecurityContext getContext() {
if (this.context == null) {
this.context = createEmptyContext();
}
@@ -38,7 +38,7 @@ public class MockSecurityContextHolderStrategy implements SecurityContextHolderS
}
@Override
public void setContext(SecurityContext context) {
public synchronized void setContext(SecurityContext context) {
this.context = context;
}
@@ -114,7 +114,7 @@ public class SecurityNamespaceHandlerTests {
"<user-service id='us'><user name='bob' password='bobspassword' authorities='ROLE_A' /></user-service>",
"3.0.3", null))
.withMessageContaining(
"You cannot use any XSD older than spring-security-7.1.xsd. Either change to spring-security.xsd or spring-security-7.1.xsd");
"You cannot use any XSD older than spring-security-7.2.xsd. Either change to spring-security.xsd or spring-security-7.2.xsd");
}
// SEC-1868
@@ -20,6 +20,7 @@ import java.util.Arrays;
import java.util.Collections;
import com.google.common.net.HttpHeaders;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -75,6 +76,15 @@ public class CorsConfigurerTests {
+ "or are publishing a `CorsConfigurationSource` bean.");
}
// FIXME: Spring Framework 7.1 removed HandlerMappingIntrospector, so there is no
// longer a CorsConfigurationSource derivable from implicit @CrossOrigin/MVC config,
// and PreFlightRequestFilter (the replacement) is a no-op for non-preflight
// requests. Per https://github.com/spring-projects/spring-framework/issues/36481,
// relying on implicit config for a plain request's CORS headers was "never an
// intended way of using HandlerMappingIntrospector" and is not coming back; decide
// whether to update this test to require an explicit CorsConfigurationSource bean
// (matching the reactive stack's always-explicit model), then re-enable.
@Disabled
@Test
public void getWhenCrossOriginAnnotationThenRespondsWithCorsHeaders() throws Exception {
this.spring.register(MvcCorsConfig.class).autowire();
@@ -95,6 +105,9 @@ public class CorsConfigurerTests {
.andExpect(header().exists("X-Content-Type-Options"));
}
// FIXME: see FIXME on getWhenCrossOriginAnnotationThenRespondsWithCorsHeaders above;
// same root cause (Framework 7.1 removed HandlerMappingIntrospector).
@Disabled
@Test
public void getWhenDefaultsInLambdaAndCrossOriginAnnotationThenRespondsWithCorsHeaders() throws Exception {
this.spring.register(MvcCorsInLambdaConfig.class).autowire();
@@ -182,6 +182,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* @author Josh Cummings
* @author Evgeniy Cheban
*/
@SuppressWarnings("removal")
@ExtendWith(SpringTestContextExtension.class)
public class OAuth2ResourceServerConfigurerTests {
@@ -65,7 +65,7 @@ public class XsdDocumentedTests {
String schema31xDocumentLocation = "org/springframework/security/config/spring-security-3.1.xsd";
String schemaDocumentLocation = "org/springframework/security/config/spring-security-7.1.xsd";
String schemaDocumentLocation = "org/springframework/security/config/spring-security-7.2.xsd";
XmlSupport xml = new XmlSupport();
@@ -151,8 +151,8 @@ public class XsdDocumentedTests {
.list((dir, name) -> name.endsWith(".xsd"));
// @formatter:on
assertThat(schemas.length)
.withFailMessage("the count is equal to 29, if not then schemaDocument needs updating")
.isEqualTo(29);
.withFailMessage("the count is equal to 30, if not then schemaDocument needs updating")
.isEqualTo(30);
}
/**
@@ -18,6 +18,9 @@ package org.springframework.security.config.http;
import java.util.Arrays;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -35,6 +38,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.PreFlightRequestHandler;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -67,6 +71,14 @@ public class HttpCorsConfigTests {
"Please ensure Spring Security & Spring MVC are configured in a shared ApplicationContext");
}
// FIXME: Spring Framework 7.1 removed HandlerMappingIntrospector, which this test's
// implicit (no configuration-source-ref) <cors/> scenario relied on to add CORS
// headers to a plain, non-preflight request before authorization runs. Per
// https://github.com/spring-projects/spring-framework/issues/36481, this was "never
// an intended way of using HandlerMappingIntrospector" and is not coming back;
// decide whether to update this test's expectations (e.g. require an explicit
// CorsConfigurationSource bean) or remove the assertion, then re-enable.
@Disabled
@Test
public void getWhenUsingCorsThenDoesSpringSecurityCorsHandshake() throws Exception {
this.spring.configLocations(this.xml("WithCors")).autowire();
@@ -106,6 +118,19 @@ public class HttpCorsConfigTests {
// @formatter:on
}
@Test
public void optionsWhenUsingPreFlightRequestHandlerThenHandlesPreFlightRequest() throws Exception {
this.spring.configLocations(this.xml("WithPreFlightRequestHandler")).autowire();
// @formatter:off
this.mvc.perform(get("/").with(this.approved()))
.andExpect(header().doesNotExist("X-Pre-Flight"))
.andExpect(status().isIAmATeapot());
this.mvc.perform(options("/").with(this.preflight()))
.andExpect(status().isOk())
.andExpect(header().exists("X-Pre-Flight"));
// @formatter:on
}
private String xml(String configName) {
return CONFIG_LOCATION_PREFIX + "-" + configName + ".xml";
}
@@ -158,4 +183,13 @@ public class HttpCorsConfigTests {
}
static class MyPreFlightRequestHandler implements PreFlightRequestHandler {
@Override
public void handlePreFlight(HttpServletRequest request, HttpServletResponse response) {
response.addHeader("X-Pre-Flight", "Handled");
}
}
}
@@ -124,6 +124,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
/**
* @author Josh Cummings
*/
@SuppressWarnings("removal")
@ExtendWith({ SpringExtension.class, SpringTestContextExtension.class })
@SecurityTestExecutionListeners
public class OAuth2ResourceServerBeanDefinitionParserTests {
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2004-present 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.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<b:beans xmlns:b="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/security
https://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd">
<http entry-point-ref="ep">
<intercept-url pattern="/**" access="authenticated"/>
<cors/>
</http>
<b:bean name="ep" class="org.springframework.security.web.authentication.HttpStatusEntryPoint">
<b:constructor-arg value="I_AM_A_TEAPOT"/>
</b:bean>
<b:bean name="preFlightRequestHandler"
class="org.springframework.security.config.http.HttpCorsConfigTests.MyPreFlightRequestHandler"/>
<b:import resource="userservice.xml"/>
</b:beans>

Some files were not shown because too many files have changed in this diff Show More