GitHub user ewesten added a comment to the discussion: [Question] how to ensure 
child threads have same subject as parent thread

Hello,

ok, I did some further debugging and found one way which seems to work

```
SecurityManager securityManager = SecurityUtils.getSecurityManager();
Subject subject = SecurityUtils.getSubject();
Runnable task = () -> {
   try {
      ThreadContext.bind(securityManager);
      ThreadContext.bind(subject);
      // my code with access control check based on principal
    } finally {
      ThreadContext.remove();
    }
};
```

The problem was that `subject.associateWith(task)` did not ensure that the 
subject within the child thread is properly resolved as needed for obtaining 
the principal. Specifically, there was no session associated with the subject 
in the child thread.

Can you confirm that this is a valid approach to solve the challenge?

Thanks, Eric

GitHub link: 
https://github.com/apache/shiro/discussions/2413#discussioncomment-15170526

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to