Skip to content

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

Merged
merged 4 commits into from
Feb 12, 2020

Conversation

tvernum
Copy link
Contributor

@tvernum tvernum commented Feb 8, 2020

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).

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).
@tvernum tvernum added >non-issue :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v8.0.0 v7.7.0 labels Feb 8, 2020
@tvernum tvernum requested a review from jkakavas February 8, 2020 09:18
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (:Security/Authentication)

@tvernum
Copy link
Contributor Author

tvernum commented Feb 8, 2020

This is needed for secondary authc support, since the secondary authenticator should never fall back to anonymous.

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,
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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

@tvernum tvernum requested a review from jkakavas February 11, 2020 10:20
Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tvernum tvernum merged commit ec1afb9 into elastic:master Feb 12, 2020
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Mar 13, 2020
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
tvernum added a commit that referenced this pull request Mar 13, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v7.7.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants