- Notifications
You must be signed in to change notification settings - Fork 25.6k
Handle cross-cluster authentication in authorization info report #95203
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
Handle cross-cluster authentication in authorization info report #95203
Conversation
This PR adds support for reporting authorization information for cross-cluster authentication.
| Pinging @elastic/es-security (Team:Security) |
| builder.startObject("cross_cluster_access"); | ||
| { | ||
| addApiKeyInfo(builder, subject); | ||
| builder.startObject("remote_authorization"); |
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.
This field is named remote_authorization to be both different from and consistent with the outer authorization field. I am open to suggestions.
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.
Ya I think remote_authorization works. Only alternative I can think of is authorization_from_remote but I don't have a preference either way.
| } | ||
| case SERVICE_ACCOUNT -> builder.field("service_account", authenticationSubject.getUser().principal()); | ||
| case SERVICE_ACCOUNT -> builder.field("service_account", subject.getUser().principal()); | ||
| case CROSS_CLUSTER_ACCESS -> { |
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.
Based on the callers of this method, a cross-cluster authentication should never reach here. Therefore it can be argued to not handle it at all, e.g. just return without doing anything. However since the method itself is not prescribed to be used only by existing callers, it feels more appropriate to handle the case for self-consistency.
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.
++ on just supporting it
n1v0lg left a comment
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
| AuthenticationTestHelper.builder().build() | ||
| ); | ||
| assert false == crossClusterAccessSubjectInfo.getAuthentication().isCrossClusterAccess(); | ||
| final Authentication authentication = AuthenticationTestHelper.builder() |
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.
Nit: I think we can just use builder.crossCluster().build() instead, i.e.:
final Authentication authentication = AuthenticationTestHelper.builder().crossClusterAccess().build(); final var apiKeyName = (String) authentication.getAuthenticatingSubject().getMetadata().get(API_KEY_NAME_KEY); final var innerAuthentication = (Authentication) authentication.getAuthenticatingSubject() .getMetadata() .get(CROSS_CLUSTER_ACCESS_AUTHENTICATION_KEY);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.
Thanks I forgot we have this convenient method.
| builder.startObject("cross_cluster_access"); | ||
| { | ||
| addApiKeyInfo(builder, subject); | ||
| builder.startObject("remote_authorization"); |
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.
Ya I think remote_authorization works. Only alternative I can think of is authorization_from_remote but I don't have a preference either way.
| } | ||
| case SERVICE_ACCOUNT -> builder.field("service_account", authenticationSubject.getUser().principal()); | ||
| case SERVICE_ACCOUNT -> builder.field("service_account", subject.getUser().principal()); | ||
| case CROSS_CLUSTER_ACCESS -> { |
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.
++ on just supporting it
This PR adds support for reporting authorization information for cross-cluster authentication.
Note: Labelled as
>non-issuebecause the cross-cluster-access is still behind feature flag.