Skip to content

Commit f62c9d3

Browse files
Merge branch '6.0.x' into 6.1.x
Closes gh-13494
2 parents 0579be0 + 933b302 commit f62c9d3

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ private void createFilterSecurityInterceptor(BeanReference authManager) {
781781
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(FilterSecurityInterceptor.class);
782782
builder.addPropertyReference("accessDecisionManager", accessManagerId);
783783
builder.addPropertyValue("authenticationManager", authManager);
784-
if ("false".equals(this.httpElt.getAttribute(ATT_ONCE_PER_REQUEST))) {
785-
builder.addPropertyValue("observeOncePerRequest", Boolean.FALSE);
784+
if ("true".equals(this.httpElt.getAttribute(ATT_ONCE_PER_REQUEST))) {
785+
builder.addPropertyValue("observeOncePerRequest", Boolean.TRUE);
786786
}
787787
builder.addPropertyValue("securityMetadataSource", securityMds);
788788
builder.addPropertyValue("securityContextHolderStrategy", this.holderStrategyRef);

config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ public void configureWhenOncePerRequestIsFalseThenFilterSecurityInterceptorExerc
323323
assertThat(filterSecurityInterceptor.isObserveOncePerRequest()).isFalse();
324324
}
325325

326+
@Test
327+
public void configureWhenOncePerRequestIsTrueThenFilterSecurityInterceptorObserveOncePerRequestIsTrue() {
328+
this.spring.configLocations(xml("OncePerRequestTrue")).autowire();
329+
FilterSecurityInterceptor filterSecurityInterceptor = getFilter(FilterSecurityInterceptor.class);
330+
assertThat(filterSecurityInterceptor.isObserveOncePerRequest()).isTrue();
331+
}
332+
326333
@Test
327334
public void requestWhenCustomHttpBasicEntryPointRefThenInvokesOnCommence() throws Exception {
328335
this.spring.configLocations(xml("CustomHttpBasicEntryPointRef")).autowire();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2002-2023 the original author or authors.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<b:beans xmlns:b="http://www.springframework.org/schema/beans"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xmlns="http://www.springframework.org/schema/security"
21+
xsi:schemaLocation="
22+
http://www.springframework.org/schema/security
23+
https://www.springframework.org/schema/security/spring-security.xsd
24+
http://www.springframework.org/schema/beans
25+
https://www.springframework.org/schema/beans/spring-beans.xsd">
26+
27+
<http once-per-request="true" use-authorization-manager="false">
28+
<http-basic/>
29+
<intercept-url pattern="/protected" access="authenticated"/>
30+
<intercept-url pattern="/unprotected-forwards-to-protected" access="permitAll"/>
31+
</http>
32+
33+
<b:import resource="userservice.xml"/>
34+
<b:import resource="handlermappingintrospector.xml"/>
35+
</b:beans>

0 commit comments

Comments
 (0)