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

Simplify API key service API #44935

Conversation

bizybot
Copy link
Contributor

@bizybot bizybot commented Jul 29, 2019

This commit merely refactors API key service interface
for retrieving and invalidating API keys.
The service layer need not do any authorization so we do not need
multiple interfaces to retrieve or invalidate API keys but one interface
to do each operation.

Relates #40031

This commit merely refactors API key service interface
for retrieving and invalidating API keys.
This avoids the use of `*Response` classes to service layer.
The service layer need not do any authorization so we do not need
multiple ways to retrieve or invalidate API keys but one interface
to do each operation.
@bizybot bizybot added :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC v8.0.0 v7.4.0 labels Jul 29, 2019
@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.

Just some minor nits, otherwise LGTM.

static final GetApiKeysResult EMPTY_RESULT = new GetApiKeysResult(Collections.emptyList());
private final Collection<ApiKey> foundApiKeysInfo;

public GetApiKeysResult(Collection<ApiKey> foundApiKeysInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make this constructor look more like InvalidateApiKeysResult.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ScrollHelper.fetchAllByEntity returns a Collection<T> and so this is a Collection than a List, avoiding the conversion here.

@tvernum
Copy link
Contributor

tvernum commented Aug 1, 2019

I don't think there's any need to create *Result classes that exactly mimic the *Response classes.
If the the Action and Service need different interfaces, then fine, but if they're the same response data, then let's just have a single implementation.

@bizybot bizybot changed the title Simplify API key service API and avoid *Response in service layer Simplify API key service API Aug 1, 2019
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, with a couple of nits.

@bizybot
Copy link
Contributor Author

bizybot commented Aug 6, 2019

@elasticmachine test this please

@bizybot bizybot merged commit 9e61a9c into elastic:manage-own-api-key-privilege Aug 6, 2019
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