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

[Kerberos] Remove realm from principal name #31928

Merged
merged 5 commits into from
Jul 12, 2018

Conversation

bizybot
Copy link
Contributor

@bizybot bizybot commented Jul 10, 2018

This commit adds support for removing realm name
from the Kerberos principal name. The principal names in
Kerberos are in the form primary/instance@realm.
Since we will be supporting user lookups and depending on the
scenario we may want to remove the REALM part and use the username
for lookup or role mapping.
This change adds a new setting with the default value false to
control removing of realm name.
Modified tests to randomly use this setting during testing.

This commit adds setting for stripping realm name
from the Kerberos principal name. The principal names in
Kerberos are in the form `primary/instance@realm`.
Since we will be supporting user lookups and depending on the
scenario we may want to strip the REALM part and use the username
for lookup or role mapping.
This change adds new setting with default value `false`. Also
modified tests to randomly use this setting during Kerberos testing.
@bizybot bizybot added >feature :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) labels Jul 10, 2018
@bizybot bizybot requested review from tvernum and jaymode July 10, 2018 14:42
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

I left some minor comments about naming

@@ -27,6 +27,8 @@
Setting.simpleString("keytab.path", Property.NodeScope);
public static final Setting<Boolean> SETTING_KRB_DEBUG_ENABLE =
Setting.boolSetting("krb.debug", Boolean.FALSE, Property.NodeScope);
public static final Setting<Boolean> SETTING_STRIP_REALM_NAME =
Setting.boolSetting("strip.realm_name", Boolean.FALSE, Property.NodeScope);
Copy link
Member

Choose a reason for hiding this comment

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

what about include_realm_name with a default of true? or remove_realm_name with a default of false? @tvernum thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed this to remove_realm_name with a default of false. Will change if Tim suggests something else. Thank you.

* @param principalName user principal name
* @return result string after stripping realm name
*/
private String stripRealmName(final String principalName) {
Copy link
Member

Choose a reason for hiding this comment

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

this should probably be named something like maybeRemoveRealmName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, Thank you.

@@ -76,7 +76,8 @@ public void testAuthenticateDifferentFailureScenarios() throws LoginException, G
assertThat(result.getStatus(), is(equalTo(AuthenticationResult.Status.CONTINUE)));
} else {
if (validTicket) {
final User expectedUser = new User(username, roles.toArray(new String[roles.size()]), null, null, null, true);
final User expectedUser = new User(stripRealmName(username), roles.toArray(new String[roles.size()]), null, null, null,
Copy link
Member

Choose a reason for hiding this comment

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

nit: its much cleaner if you just move the whole new User(... statement to a new line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, changes it. Thank you.

@bizybot bizybot changed the title [Kerberos] Strip realm from principal name [Kerberos] Remove realm from principal name Jul 11, 2018
Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

@bizybot bizybot merged commit 375954f into elastic:feature/kerberos Jul 12, 2018
@bizybot bizybot deleted the kerberos/striprealmname branch July 12, 2018 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>feature :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants