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

Commit

Permalink
Propagte security context to threads created by spring
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rgolangh authored and openshift-merge-robot committed Jun 7, 2023
1 parent fe8602e commit e98e9bc
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.data.util.Pair;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
Expand Down Expand Up @@ -95,6 +96,7 @@ public BeanWorkFlowRegistryImpl(ConfigurableListableBeanFactory beanFactory, Map

@PostConstruct
void postInit() {
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
workFlowDefinitionService.cleanAllDefinitionMappings();
saveWorkFlow();
saveChecker();
Expand Down

0 comments on commit e98e9bc

Please sign in to comment.