-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagate security context via channel interceptor #12532
Propagate security context via channel interceptor #12532
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@artembilan, thanks for the PR! I've left some questions inline.
...a/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java
Outdated
Show resolved
Hide resolved
...a/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @artembilan! I've left some additional feedback inline.
...n/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptor.java
Outdated
Show resolved
Hide resolved
...a/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java
Outdated
Show resolved
Hide resolved
...n/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptor.java
Outdated
Show resolved
Hide resolved
f26515f
to
0130a47
Compare
@jzheaux , any feedback, please? |
Here is some simple Spring Boot sample to demonstrate how a new |
bdd0914
to
4f2989d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for moving this out into another class, and also for the sample! Please see my next round of questions/comments inline.
...springframework/security/messaging/context/SecurityContextPropagationChannelInterceptor.java
Outdated
Show resolved
Hide resolved
...a/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java
Outdated
Show resolved
Hide resolved
...n/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptor.java
Outdated
Show resolved
Hide resolved
...springframework/security/messaging/context/SecurityContextPropagationChannelInterceptor.java
Outdated
Show resolved
Hide resolved
...springframework/security/messaging/context/SecurityContextPropagationChannelInterceptor.java
Outdated
Show resolved
Hide resolved
4f2989d
to
e8c9869
Compare
Just pushed the rest of requested changes. Thanks |
Pushed an anonymous propagation as was requested. |
Add `SecurityContextPropagationChannelInterceptor` that propagates the current security context through the Spring Messaging API. Namely, it adds the current security context into any message before it is sent and then populates the security context when that message is received, typically in a separate thread.
9847108
to
60a00bb
Compare
The
SecurityContextChannelInterceptor
currently has an ability to populate a security context with anAuthentication
from message header. But doesn't look like there is a way in the framework to populate such a header and therefore propagate context downstream the messaging flowSecurityContextChannelInterceptor
to supportpostReceive()
contract for context population andafterReceiveCompletion()
to clean it up, respectivelysetup()
function logic to not re-populate context if it already has the sameAuthentication
preSend()
to populate header with the value from current security context if it is missed in a messageThe change is driven by this Spring Integration feature: https://docs.spring.io/spring-integration/reference/html/security.html#security-context-propagation.
There is now only a single class in the Spring Integration Security modules and it is that
SecurityContextPropagationChannelInterceptor
.When we will have such a propagation feature in Spring Security for Messaging by itself, there won't be a reason in that module in Spring Integration at all.