-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into autoconfig_for_prooftoken_validation
- Loading branch information
Showing
12 changed files
with
140 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
spring-security-starter/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.springframework.boot.env.EnvironmentPostProcessor=\ | ||
com.sap.cloud.security.spring.autoconfig.SecurityContextEnvironmentPostProcessor |
1 change: 0 additions & 1 deletion
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
com.sap.cloud.security.spring.autoconfig.HybridIdentityServicesAutoConfiguration | ||
com.sap.cloud.security.spring.autoconfig.HybridAuthorizationAutoConfiguration | ||
com.sap.cloud.security.spring.autoconfig.XsuaaTokenFlowAutoConfiguration | ||
com.sap.cloud.security.spring.autoconfig.SecurityContextAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 0 additions & 68 deletions
68
.../main/java/com/sap/cloud/security/spring/autoconfig/SecurityContextAutoConfiguration.java
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...ava/com/sap/cloud/security/spring/autoconfig/SecurityContextEnvironmentPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2018-2023 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors | ||
* <p> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package com.sap.cloud.security.spring.autoconfig; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.env.EnvironmentPostProcessor; | ||
import org.springframework.core.env.ConfigurableEnvironment; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
import com.sap.cloud.security.spring.token.authentication.JavaSecurityContextHolderStrategy; | ||
/** | ||
* Instantiates a {@link com.sap.cloud.security.spring.token.authentication.JavaSecurityContextHolderStrategy}, which keeps the | ||
* {@code com.sap.cloud.security.token.SecurityContext} in sync | ||
* | ||
* <p> | ||
* Can be disabled with with property {@code sap.spring.security.hybrid.auto = false}. | ||
*/ | ||
public class SecurityContextEnvironmentPostProcessor implements EnvironmentPostProcessor { | ||
|
||
@Override | ||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { | ||
String autoConfig = environment.getProperty("sap.spring.security.hybrid.auto"); | ||
String syncContext = environment.getProperty("sap.spring.security.hybrid.sync_securitycontext"); | ||
if ((autoConfig == null || Boolean.valueOf(autoConfig)) && | ||
(syncContext == null || Boolean.valueOf(syncContext)) && | ||
!(SecurityContextHolder.getContextHolderStrategy() instanceof JavaSecurityContextHolderStrategy)) { | ||
SecurityContextHolder.setContextHolderStrategy(new JavaSecurityContextHolderStrategy()); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.