-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Fix owner user realm check for API key authentication #84325
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -368,7 +368,7 @@ public void toXContentFragment(XContentBuilder builder) throws IOException { | |
builder.array(User.Fields.ROLES.getPreferredName(), user.roles()); | ||
builder.field(User.Fields.FULL_NAME.getPreferredName(), user.fullName()); | ||
builder.field(User.Fields.EMAIL.getPreferredName(), user.email()); | ||
if (isAuthenticatedWithServiceAccount()) { | ||
if (isServiceAccount()) { | ||
final String tokenName = (String) getMetadata().get(ServiceAccountSettings.TOKEN_NAME_FIELD); | ||
assert tokenName != null : "token name cannot be null"; | ||
final String tokenSource = (String) getMetadata().get(ServiceAccountSettings.TOKEN_SOURCE_FIELD); | ||
|
@@ -405,7 +405,7 @@ public void toXContentFragment(XContentBuilder builder) throws IOException { | |
} | ||
builder.endObject(); | ||
builder.field(User.Fields.AUTHENTICATION_TYPE.getPreferredName(), getAuthenticationType().name().toLowerCase(Locale.ROOT)); | ||
if (isAuthenticatedWithApiKey()) { | ||
if (isApiKey()) { | ||
this.assertApiKeyMetadata(); | ||
final String apiKeyId = (String) this.metadata.get(AuthenticationField.API_KEY_ID_KEY); | ||
final String apiKeyName = (String) this.metadata.get(AuthenticationField.API_KEY_NAME_KEY); | ||
Comment on lines
-408
to
411
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change means we are not going to show API key ID and name in the authentication API response if the request is made by an API key run-as some other user. I think this makes sense. Ideally once we figure out what the effective user is, it should behave mostly the same as the user authentication itself. Also, it is plausible for certain setup, the underlying API key is not mean to reveal to the end-user. |
||
|
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.
Similar to the above: If the service account run-as another user, the service token name and type won't show up in the authentication response. This in theory could be a "breaking change" except we don't have any service account that has "run-as" privilege. So the change here is safe.