-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add option to disable anonymous authentication in RSocketSecurity
#17159
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
base: main
Are you sure you want to change the base?
Conversation
RSocketSecurity
RSocketSecurity
Hmmm, is the build going down by my mistake or is it not about me? |
Closes spring-projectsgh-17132 Signed-off-by: Andrey Litvitski <[email protected]>
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 the PR, @therepanic! I've left feedback inline.
Also, are you able to add a test that confirms that when anonymous is disabled then it isn't active in the filter chain?
* Disables anonymous authentication. | ||
* @return the builder for additional customizations | ||
*/ | ||
public RSocketSecurity disableAnonymous() { |
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.
While I agree that this is a straightforward way to expose the feature, I see some additional benefit in exposing it in a way that's similar to HttpSecurity
and ServerHttpSecurity.
Are you able to add this feature in the following way instead?
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.
I agree, that would indeed be better. I think we should add a class similar to RSocketSecurity.BasicAuthenticationSpec
, but without fields, and the build() method will execute the logic of the current anonymous() method. And I think we can remove it as unnecessary.
Thanks for review, @jzheaux! I'd be happy to add the test. I just have one question about it. I think we could make a test that checks the functionality you described by creating a new test class, let's call it |
@therepanic, that sounds like a good approach. Also, you might consider a test like
AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
ReactiveAuthorizationManager<PayloadExchange> anonymous = (authentication, exchange) ->
authentication.map(trustResolver::isAnonymous).map(AuthorizationDecision::new);
// ...
.anyExchange().access(anonymous) |
Adding anonymous interceptor hardcoded to
RSocketSecurity#payloadInterceptors
and is added anyway. I think you should add an option to disable adding anonymous interceptor.I think the most logical way is to add a flag, as in our case I did. I also added a method
disableAnonymous
which sets the field to true and we no longer add the anonymous interceptor.Fixes: #17132