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

Improve auditing of API key authentication #58928

Merged
merged 32 commits into from
Jul 9, 2020

Conversation

albertzaharovits
Copy link
Contributor

@albertzaharovits albertzaharovits commented Jul 2, 2020

These changes roughly follow #52551 (comment) after some course correct.

  • add the apikey.id, apikey.name and authentication.type fields to the access_granted, access_denied, authentication_success and (some) tampered_request audit events (apikey.id and apikey.name are present only when authn with an API Key)
  • when authn with an API Key, the user.realm field now contains the realm name of the user that created the key, instead of the synthetic value of _es_api_key. Note that in this circumstance, the user.name field reflects the name of the user that created the key (they are consistent)
  • user.roles contains the role names (only of found/resolved roles) of the user that created the key. It previously wrongly had the role descriptor names from the API key definition. This is now handled separately in Ensure authz role for API key is named after owner role #59041 .

Relates #52551

@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Security Meta label for security team label Jul 2, 2020
Runnable action = () -> {
logger.trace("Established authentication [{}] for request [{}]", authentication, request);
listener.onResponse(authentication);
};
try {
authenticationSerializer.writeToContext(authentication, threadContext);
request.authenticationSuccess(authentication);
} catch (Exception e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving the auditing of authentication_success down here avoids the unlikely, but confusing case of authentication_success followed by authentication_failed.

user = new User("hulk", new String[] { "superuser" }, new User("authenticated_user", new String[] { "other" }));
} else {
user = new User("hulk", new String[] { "superuser" });
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

mix-in creating an API Key while running-as.

@albertzaharovits albertzaharovits requested a review from ywangd July 5, 2020 18:37
@albertzaharovits
Copy link
Contributor Author

@ywangd @tvernum ready for another round. Thanks!

Copy link
Contributor

@tvernum tvernum left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

@albertzaharovits albertzaharovits merged commit 83cf22a into elastic:master Jul 9, 2020
@albertzaharovits albertzaharovits deleted the audit_key_usage branch July 9, 2020 09:34
albertzaharovits added a commit that referenced this pull request Jul 9, 2020
1. Add the `apikey.id`, `apikey.name` and `authentication.type` fields
to the `access_granted`, `access_denied`, `authentication_success`, and
(some) `tampered_request` audit events. The `apikey.id` and `apikey.name`
are present only when authn using an API Key.
2. When authn with an API Key, the `user.realm` field now contains the effective
realm name of the user that created the key, instead of the synthetic value of
`_es_api_key`.
albertzaharovits added a commit that referenced this pull request Jul 23, 2020
This PR describes the new audit entry attributes api_key.id,
api_key.name and authentication.type, as well as the meaning of
existing attributes when authentication is performed using API keys.

This should've been part of #58928
albertzaharovits added a commit that referenced this pull request Jul 23, 2020
This PR describes the new audit entry attributes api_key.id,
api_key.name and authentication.type, as well as the meaning of
existing attributes when authentication is performed using API keys.

This should've been part of #58928
albertzaharovits added a commit that referenced this pull request Jul 23, 2020
This PR describes the new audit entry attributes api_key.id,
api_key.name and authentication.type, as well as the meaning of
existing attributes when authentication is performed using API keys.

This should've been part of #58928
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Security/Audit X-Pack Audit logging Team:Security Meta label for security team v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants