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

API Key id part of transport request body #63221

Conversation

albertzaharovits
Copy link
Contributor

When auditing API key creation, it is useful to show the id of the key together with its other parameters (such as name and expiration, etc). Because auditing shows request bodies of security transport actions (see #62916), the id must be part of the request body for it to be audited.

Because the API Key id is the doc id of the key doc in the .security index, this change moves the id generation from

to the request constructor.

@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Security Meta label for security team label Oct 4, 2020
Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -45,13 +49,19 @@ public CreateApiKeyRequest() {}
* @param expiration to specify expiration for the API key
*/
public CreateApiKeyRequest(String name, @Nullable List<RoleDescriptor> roleDescriptors, @Nullable TimeValue expiration) {
this.id = UUIDs.base64UUID();
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would add a comment as it is not obvious why we would generate the id ( in the same way it would be autogenerated as the doc id ) here

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, I'll do that, I wanted to do that, thanks.

@@ -96,11 +97,22 @@ public void testSerialization() throws IOException {
}
request.setRoleDescriptors(descriptorList);

boolean testV710Bwc = true;// randomBoolean();
Copy link
Member

Choose a reason for hiding this comment

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

Uncomment the randomBoolean()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aaarg, it should be randomBoolean . Thanks for catching Yang!

@albertzaharovits
Copy link
Contributor Author

@elasticmachine update branch

@albertzaharovits albertzaharovits merged commit 5fa5e81 into elastic:master Oct 5, 2020
@albertzaharovits albertzaharovits deleted the create_api_key_id_part_of_request branch October 5, 2020 20:31
@tvernum
Copy link
Contributor

tvernum commented Oct 6, 2020

Can we discuss this please? I think it has wider implications than have been accounted for.

albertzaharovits added a commit that referenced this pull request Dec 17, 2020
This adds a new method to the AuditTrail that intercepts the
responses of transport-level actions. This new method is unlike all
the other existing audit methods because it is called after the
action has been run (so that it has access to the response).
After careful deliberation, the new method is called for the
responses of actions that are intercepted by the
`SecurityActionFilter` only, and not by the transport filter.

In order to facilitate the "linking" of the new audit event with the
other existing events, the audit method receives the requestId
as well as the authentication as arguments (in addition to the
request itself and the response).

This is labeled non-issue because it is only the foundation
upon which later features that actually print out (some) responses
can be built upon.

Related #63221
albertzaharovits added a commit to albertzaharovits/elasticsearch that referenced this pull request Dec 17, 2020
This adds a new method to the AuditTrail that intercepts the
responses of transport-level actions. This new method is unlike all
the other existing audit methods because it is called after the
action has been run (so that it has access to the response).
After careful deliberation, the new method is called for the
responses of actions that are intercepted by the
`SecurityActionFilter` only, and not by the transport filter.

In order to facilitate the "linking" of the new audit event with the
other existing events, the audit method receives the requestId
as well as the authentication as arguments (in addition to the
request itself and the response).

This is labeled non-issue because it is only the foundation
upon which later features that actually print out (some) responses
can be built upon.

Related elastic#63221
albertzaharovits added a commit that referenced this pull request Dec 17, 2020
This adds a new method to the AuditTrail that intercepts the
responses of transport-level actions. This new method is unlike all
the other existing audit methods because it is called after the
action has been run (so that it has access to the response).
After careful deliberation, the new method is called for the
responses of actions that are intercepted by the
`SecurityActionFilter` only, and not by the transport filter.

In order to facilitate the "linking" of the new audit event with the
other existing events, the audit method receives the requestId
as well as the authentication as arguments (in addition to the
request itself and the response).

This is labeled non-issue because it is only the foundation
upon which later features that actually print out (some) responses
can be built upon.

Related #63221
@jakelandis jakelandis removed the v8.0.0 label Jul 26, 2021
ywangd added a commit to ywangd/elasticsearch that referenced this pull request Jul 12, 2022
The API key ID generation is handled by the Request class since elastic#63221.
This makes it possible to audit it when creating or granting API keys.
This PR makes the necessary changes for it to happen.

Relates: elastic#63221
ywangd added a commit that referenced this pull request Jul 12, 2022
The API key ID generation is handled by the Request class since #63221.
This makes it possible to audit it when creating or granting API keys.
This PR makes the necessary changes for it to happen.

Relates: #63221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants