-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
[Kerberos] Remove realm from principal name #31928
Conversation
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.
Pinging @elastic/es-security |
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 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); |
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.
what about include_realm_name
with a default of true? or remove_realm_name
with a default of false? @tvernum thoughts?
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.
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) { |
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.
this should probably be named something like maybeRemoveRealmName
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.
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, |
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.
nit: its much cleaner if you just move the whole new User(...
statement to a new line
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.
Yes, changes it. Thank you.
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 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
tocontrol removing of realm name.
Modified tests to randomly use this setting during testing.