Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Propagte security context to threads created by spring #406

Conversation

rgolangh
Copy link
Contributor

@rgolangh rgolangh commented Jun 7, 2023

Motivation
All flow and task execution are async (@async) and All
of them are lacking the security context. This means sending
notification or any other action that needs this info is lacking it.

Modification
Configure the context strategy on bootup time so every thread that
spring creates will inherit the security context.

Result
Sending notifications using the Notifier interface doesn't need any user
information

Gaps
Workflows that are continued upon server restart are probably missing
this information and we need to probably fetch the user info from the DB
and rebuild the security context.

Signed-off-by: Roy Golan rgolan@redhat.com

@openshift-ci openshift-ci bot requested review from lshannon and masayag June 7, 2023 12:26
@openshift-ci openshift-ci bot added the approved label Jun 7, 2023
@@ -44,4 +47,9 @@ public static void main(String[] args) {
SpringApplication.run(WorkflowServiceApplication.class, args);
}

@Bean
public InitializingBean initializingBean() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of this, can we add SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL) to postInit() in BeanWorkFlowRegistryImpl? or we can move it to some Configuration class. I think put it in main might not be a good idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configurations should subject to different profiles

Motivation
All flow and task execution are async (@async) and All
of them are lacking the security context. This means sending
notification or any other action that needs this info is lacking it.

Modification
Configure the context strategy on bootup time so every thread that
spring creates will inherit the security context.

Result
Sending notifications using the Notifier interface doesn't need any user
information

Gaps
Workflows that are continued upon server restart are probably missing
this information and we need to probably fetch the user info from the DB
and rebuild the security context.

Signed-off-by: Roy Golan <rgolan@redhat.com>
@rgolangh rgolangh force-pushed the propagate-security-context-to-threads branch from 370a9fc to 7991267 Compare June 7, 2023 13:17
@openshift-ci
Copy link

openshift-ci bot commented Jun 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RichardW98

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@RichardW98 RichardW98 added the lgtm label Jun 7, 2023
@openshift-merge-robot openshift-merge-robot merged commit e98e9bc into parodos-dev:main Jun 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants