-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Support authentication without anonymous user #52094
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
Support authentication without anonymous user #52094
Conversation
This change adds a new parameter to the authenticate methods in the AuthenticationService to optionally exclude support for the anonymous user (if an anonymous user exists).
Pinging @elastic/es-security (:Security/Authentication) |
This is needed for secondary authc support, since the secondary authenticator should never fall back to anonymous. |
...gin/security/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationService.java
Show resolved
Hide resolved
...gin/security/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationService.java
Outdated
Show resolved
Hide resolved
...urity/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java
Outdated
Show resolved
Hide resolved
Authenticator(String action, TransportMessage message, User fallbackUser, ActionListener<Authentication> listener) { | ||
this(new AuditableTransportRequest(auditTrail, failureHandler, threadContext, action, message | ||
), fallbackUser, listener); | ||
Authenticator(String action, TransportMessage message, User fallbackUser, boolean fallbackToAnonymous, |
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.
Since fallbackToAnonymous
makes no sense when fallbackUser
is passed in and not null, I'm wondering if this is clearer to have a ctor and a #createAuthenticator()
without the fallbackToAnonymous
parameter and Objects.notNull for the fallbackUser
. It feels like it would be simpler to argue about or understand while reading the code.
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.
The other option is to merge the two options (fallbackUser
and fallbacktoAnonymous
) into a single field in some way. Right now those two cases in handleNullToken
are almost identical.
There's just enough minor differences to make it a bit tricky though.
I could make it a Supplier<Authentication> fallback
, but I don't think I'd get anything cleaner than that.
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.
@jkakavas Let me know if you'd like to see that change. I've implemented it as you suggested for now, but could do more.
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 think this is clean enough. Maybe we can reconsider additional changes in the refactoring effort that will follow at some point
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.
LGTM
This change adds a new parameter to the authenticate methods in the AuthenticationService to optionally exclude support for the anonymous user (if an anonymous user exists). Backport of: elastic#52094
This change adds a new parameter to the authenticate methods in the AuthenticationService to optionally exclude support for the anonymous user (if an anonymous user exists). Backport of: #52094
This change adds a new parameter to the authenticate methods in the
AuthenticationService to optionally exclude support for the anonymous
user (if an anonymous user exists).