Skip to content

SEC-3109: Concurrent/ThreadPoolTaskScheduler don't work with DelegatingSecurityContextExecutor #3311

@spring-projects-issues

Description

@spring-projects-issues

Matthias Nöbl (Migrated from SEC-3109) said:

We have a setup with Spring Boot with scheduling. To use method security with background jobs we want to use the DelegatingSecurityContextScheduledExecutorService like described here: http://www.petrikainulainen.net/programming/spring-framework/spring-from-the-trenches-invoking-a-secured-method-from-a-scheduled-job/ (see "Spring Security 3.2: It Is Almost Like Magic!").

I suspect this stopped working with SEC-3031, because now DelegatingSecurityContextRunnable/Callable doesn't set/clear the security context if run on the same thread as they were created.
As Concurrent/TheadPoolTaskScheduler uses a ReschedulingRunnable for the trigger mechanic (we use cron triggers), so the rescheduling is done on the pool thread. So random subsequent calls executed on the same pool thread might fail, because the SecurityContext is not set.
Getting DelegatingSecurityContextExecutor to set the enableOnOriginalThread property on DelegatingSecurityContextRunnable to true would fix that issue.

Metadata

Metadata

Assignees

Labels

type: bugA general bugtype: jiraAn issue that was migrated from JIRA

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions