-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Consolidate user role resolution for API keys #88542
Consolidate user role resolution for API keys #88542
Conversation
ApiKeyGenerator
to handle API key updates
|
||
import java.util.Set; | ||
|
||
public class ApiKeyUserRoleDescriptorResolver { |
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.
I can also add a test for ApiKeyUpdateHandler
however it's very simple and already exercised by our integration tests.
Pinging @elastic/es-security (Team:Security) |
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.
The essence of ApiKeyGenerator
is really just about resolving the owner user's role descriptors. Once this part is refactored out to its own class, there is no good reason to still keep this class around. I'd suggest we simply remove it and let the handler classes (TransportCreateApiKeyAction
and TransportGrantApiKeyAction
etc) to be the true handlers. It will be a bit bigger change. But that's OK for a refactoring PR.
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.
LGTM
This refactor extracts the user role resolution logic for API keys from
ApiKeyGenerator
. It plugs the shared resolver class into API keycreation and update handling. It also removes
ApiKeyGenerator
sincethe class is now trivial. A new REST base handler for API key-related
REST actions ensures that the API key service is enabled before we
perform role resolution, which was the only other responsibility left
to
ApiKeyGenerator
.Relates:
https://github.com/elastic/elasticsearch/pull/88186/files#r910515818