This is an automated email from the ASF dual-hosted git repository.
pefernan pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new 7298dc74de [incubator-kie-issues#2086] Enable
SecurityContextHolder.MODE_INHERITABLETHREADLOCAL for Spring Boot graphql
security context propagation (#4053)
7298dc74de is described below
commit 7298dc74ded08126bb2dddfdd947456d46d043e9
Author: Martin Weiler <[email protected]>
AuthorDate: Tue Sep 9 00:28:41 2025 -0600
[incubator-kie-issues#2086] Enable
SecurityContextHolder.MODE_INHERITABLETHREADLOCAL for Spring Boot graphql
security context propagation (#4053)
* [incubator-kie-issues#2086] Enable
SecurityContextHolder.MODE_INHERITABLETHREADLOCAL for Spring Boot graphql
security context propagation
* - Moving `SecurityContextHolder` initialization to `InitializingBean`
---------
Co-authored-by: Pere Fernández <[email protected]>
---
.../auth/SecurityContextInitializer.java | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git
a/springboot/addons/common/common-auth/src/main/java/org/kie/addons/springboot/auth/SecurityContextInitializer.java
b/springboot/addons/common/common-auth/src/main/java/org/kie/addons/springboot/auth/SecurityContextInitializer.java
new file mode 100644
index 0000000000..fa3327e6fc
--- /dev/null
+++
b/springboot/addons/common/common-auth/src/main/java/org/kie/addons/springboot/auth/SecurityContextInitializer.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://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.kie.addons.springboot.auth;
+
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SecurityContextInitializer implements InitializingBean {
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ // ensure the security context is inherited to child threads
+
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]