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

Make role descriptors optional when creating API keys #43481

Merged
merged 6 commits into from
Jun 25, 2019

Conversation

bizybot
Copy link
Contributor

@bizybot bizybot commented Jun 21, 2019

This commit changes the role_descriptors field from required
to optional when creating an API key. The default behavior in .NET ES
client is to omit properties with null value requiring additional
workarounds. The behavior for the API does not change.
Field names (id, name) in the invalidate api keys API documentation have been
corrected where they were wrong.

Closes #42053

This commit changes the `role_descriptors` field from required
to optional when creating API key. The default behavior in .NET ES
client is to omit properties with `null` value requiring additional
workarounds. The behavior for the API does not change.
Field names (`id`, `name`) in the invalidate api keys API documentation have been
corrected where they were wrong.

Closes elastic#42053
@bizybot bizybot added >docs General docs changes :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v8.0.0 v7.3.0 v6.8.2 labels Jun 21, 2019
@bizybot bizybot requested a review from albertzaharovits June 21, 2019 13:07
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor nit

@@ -49,7 +49,7 @@ public CreateApiKeyRequest(String name, List<RoleDescriptor> roleDescriptors, @N
} else {
throw new IllegalArgumentException("name must not be null or empty");
}
this.roleDescriptors = Objects.requireNonNull(roleDescriptors, "role descriptors may not be null");
this.roleDescriptors = (roleDescriptors == null) ? List.of() : roleDescriptors;
Copy link
Contributor

Choose a reason for hiding this comment

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

This parameter can be annotated with @Nullable.

@@ -86,7 +86,7 @@ public void setExpiration(TimeValue expiration) {
}

public void setRoleDescriptors(List<RoleDescriptor> roleDescriptors) {
this.roleDescriptors = Collections.unmodifiableList(Objects.requireNonNull(roleDescriptors, "role descriptors may not be null"));
this.roleDescriptors = (roleDescriptors == null) ? List.of() : Collections.unmodifiableList(roleDescriptors);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are going to use List.of then Collections.unmodifiableList( should also be replaced by List.copyOf .
But, we don't have a general guidance, so I would go with the "surroundings", and raise a bigger refactoring issue for all requests? Maybe worth raising a discussion in the team's meeting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here I think we should be using List.copyOf so it is unmodifiable not not just unmodifiable view of the source. Updated here, Thank you.

@bizybot bizybot merged commit 3b87615 into elastic:master Jun 25, 2019
bizybot added a commit to bizybot/elasticsearch that referenced this pull request Jun 26, 2019
This commit changes the `role_descriptors` field from required
to optional when creating API key. The default behavior in .NET ES
client is to omit properties with `null` value requiring additional
workarounds. The behavior for the API does not change.
Field names (`id`, `name`) in the invalidate api keys API documentation have been
corrected where they were wrong.

Closes elastic#42053
bizybot added a commit to bizybot/elasticsearch that referenced this pull request Jun 26, 2019
This commit changes the `role_descriptors` field from required
to optional when creating API key. The default behavior in .NET ES
client is to omit properties with `null` value requiring additional
workarounds. The behavior for the API does not change.
Field names (`id`, `name`) in the invalidate api keys API documentation have been
corrected where they were wrong.

Closes elastic#42053
bizybot added a commit that referenced this pull request Jun 26, 2019
This commit changes the `role_descriptors` field from required
to optional when creating API key. The default behavior in .NET ES
client is to omit properties with `null` value requiring additional
workarounds. The behavior for the API does not change.
Field names (`id`, `name`) in the invalidate api keys API documentation have been
corrected where they were wrong.

Closes #42053
bizybot added a commit that referenced this pull request Jun 26, 2019
This commit changes the `role_descriptors` field from required
to optional when creating API key. The default behavior in .NET ES
client is to omit properties with `null` value requiring additional
workarounds. The behavior for the API does not change.
Field names (`id`, `name`) in the invalidate api keys API documentation have been
corrected where they were wrong.

Closes #42053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>docs General docs changes :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v6.8.2 v7.3.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Security Api Key API feedback
4 participants