Skip to content
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

Add the capability for the LDAP and AD realms to bind using Kerberos credentials #41126

Closed
wants to merge 23 commits into from

Conversation

bizybot
Copy link
Contributor

@bizybot bizybot commented Apr 11, 2019

This commit adds support for LDAP bind using SASL-GSSAPI as an
alternative to simple bind.

  • new configuration setting bind_mode with value sasl_gssapi will
    enable LDAP bind using GSSAPI. Defaults to simple bind.
  • GSSAPI bind can use either a keytab or a password.
  • Actual authentication to LDAP realm would not use GSSAPI.

Testing is done by enabling SASL on OpenLDAP and mapping a user
from Kerberos(mapped to bind DN) in a dockerized environment.
Verified the GSSAPI bind happens either using keytab or credentials.

Closes #39878

@bizybot
Copy link
Contributor Author

bizybot commented Apr 11, 2019

@elasticmachine run elasticsearch-ci/1

@colings86 colings86 added the :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) label Apr 12, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@bizybot bizybot changed the title WIP: Add support for LDAP bind using SASL GSS-API WIP: Add support for LDAP bind using SASL GSSAPI Apr 12, 2019
@bizybot
Copy link
Contributor Author

bizybot commented Apr 15, 2019

@elasticmachine run elasticsearch-ci/packaging-sample

@bizybot
Copy link
Contributor Author

bizybot commented Apr 15, 2019

unrelated failure
@elasticmachine run elasticsearch-ci/1

@bizybot bizybot changed the title WIP: Add support for LDAP bind using SASL GSSAPI Add support for LDAP bind using SASL GSSAPI Apr 15, 2019
@bizybot bizybot marked this pull request as ready for review April 15, 2019 07:11
@colings86 colings86 added v6.7.3 and removed v6.7.2 labels Apr 17, 2019
Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

This looks solid in the test department! Nice job 👍
I have left a few comments around simplifying realm configuration, that will have repercussions on BindRequestBuilder as well.
I still have to grok the tests, but I will do that in a follow-up.

default:
throw new IllegalArgumentException("only [simple] and [sasl_gssapi] bind mode are allowed, [" + v + "] is invalid");
}
}, Setting.Property.NodeScope));
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the switch validation !
But, can't we infer the mode from if SASL_GSSAPI_PRINCIPAL is present. SASL_GSSAPI_PRINCIPAL cannot be null in the way we use the library, right? Also, using SASL_GSSAPI_PRINCIPAL together with a BIND_DN should trigger a settings validation error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now other than simple and sasl_gssapi we do not wish to support other bind types but there are other bind types via SASL that the LDAP has support for. So relying on the presence of SASL_GSSAPI_PRINCIPAL or SASL_GSSAPI_KEYTAB_PATH is something I would like to avoid.

Right now it gets ignored but I agree to throw settings validation error in presence of both BIND_DN and SASL_GSSAPI_PRINCIPAL settings. I will make these changes. Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't other bind methods not also have their setting keys namespaced similarly to sasl_gssapi ? So there would be no ambiguity? To me this is a case of namespaced settings versus conditional settings, as in #30241 . The conditional setting is harder to validate in the code, compared to the namespaced ones, because the validation of the namespaced ones is just to get the whole namespace and validate them as a group. It's also simpler from a user perspective, because he has fewer settings to worry about.

Copy link
Contributor

@albertzaharovits albertzaharovits Apr 24, 2019

Choose a reason for hiding this comment

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

This is just an opinion, do as you think, or ask for other's opinions.

permission java.util.PropertyPermission "java.security.debug","write";

permission javax.security.auth.AuthPermission "createLoginContext.GSSAPIBindRequest";
permission javax.security.auth.AuthPermission "setLoginConfiguration";
Copy link
Contributor

Choose a reason for hiding this comment

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

can't these be moved to x-pack/plugin/security/src/main/plugin-metadata/plugin-security.policy ?

Copy link
Contributor Author

@bizybot bizybot Apr 18, 2019

Choose a reason for hiding this comment

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

No, as unboundid dependencies are in the core we need to have these here. Thank you.

Copy link
Contributor

@albertzaharovits albertzaharovits Apr 24, 2019

Choose a reason for hiding this comment

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

I think these are a lot of obscure permissions we're granting for any plugin (that inherits x-pack-plugin-core). I worry especially about the maintainability. In this case I think we should move the unboundid dependency over to the security plugin. I think it should not have been a dependecy in plugin-core in the first place. The only imported class from that dependecy in plugin-core is an enum, LdapSearchScope, which I think we should emulate our own and use that in plugin-core and adapt the APIs.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ on moving the dependencies and getting the permissions in one place, though I see a TODO which I think is a non-trivial change and would require considerable thought as I am not much aware of what needs to be done here.
https://github.com/elastic/elasticsearch/blob/73bfdc4066be080dc4cad1f0521bf6ea14cded93/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java#L95..L124

I think I will pick this up later as a cleanup task. Thank you.

@albertzaharovits
Copy link
Contributor

I believe enhancements shouldn't go in patch releases.

@albertzaharovits
Copy link
Contributor

albertzaharovits commented Apr 17, 2019

And another suggestion: I would change the PR title.
The PR adds the capability for the LDAP and AD realms to bind using Kerberos credentials.
IMO, SASL and his friend GSSAPI are too low level details for the title.

@bizybot bizybot changed the title Add support for LDAP bind using SASL GSSAPI Add the capability for the LDAP and AD realms to bind using Kerberos credentials Apr 18, 2019
return bindRequest;
}

private Path validateGSSAPISettings(final byte[] bindPassword) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Call me hypercritical, but this is woefully complex. And it all stems from that conditional setting I'm gripping about...

What I don't lilke:
This class can deduce the SASL principal, if it needs to, but it cannot deduce the bind DN. So, in case it needs the bind DN, it will use the provided function for that. But the caller needs to know when the bind DN is required, so that it can pass the function. This requires for the caller to know of the internals of the BindRequestBuilder which is a violation of the abstraction.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we create a separate BindRequestBuilder for the SASL case only, and have the caller (or another wrapper) handle the decision of which BindRequest type to build, given the realm settings.

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

I had another pass and I'll admit I am opinionated on the setting topic and I would like to have someone else opinion on it. Besides that, I would also like to move the JVM permissions (and unboundid dependency) inside the security plugin and away from the plugin-core.

@albertzaharovits
Copy link
Contributor

Thank you for the iterations Yogesh!

@bizybot
Copy link
Contributor Author

bizybot commented May 1, 2019

@elasticmachine run elasticsearch-ci/1

@bizybot bizybot added v7.2.0 and removed v7.2.0 labels May 1, 2019
@jasontedor jasontedor added v7.2.0 and removed v7.2.0 labels May 1, 2019
@bizybot bizybot removed the v7.2.0 label May 2, 2019
@tvernum
Copy link
Contributor

tvernum commented Oct 31, 2019

This PR is stale and we are not planning to proceed with it at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement GSSAPIBindRequest in the LDAP Realm
7 participants