Skip to content

Conversation

@ywangd
Copy link
Member

@ywangd ywangd commented Apr 12, 2023

This PR adds support for reporting authorization information for cross-cluster authentication.

Note: Labelled as >non-issue because the cross-cluster-access is still behind feature flag.

This PR adds support for reporting authorization information for cross-cluster authentication.
@ywangd ywangd added >non-issue :Security/Security Security issues without another label v8.8.0 labels Apr 12, 2023
@ywangd ywangd requested a review from n1v0lg April 12, 2023 22:56
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Apr 12, 2023
@elasticsearchmachine
Copy link
Collaborator

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

builder.startObject("cross_cluster_access");
{
addApiKeyInfo(builder, subject);
builder.startObject("remote_authorization");
Copy link
Member Author

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.

Copy link
Contributor

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 -> {
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

++ on just supporting it

Copy link
Contributor

@n1v0lg n1v0lg left a 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()
Copy link
Contributor

@n1v0lg n1v0lg Apr 13, 2023

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);
Copy link
Member Author

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");
Copy link
Contributor

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 -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

++ on just supporting it

@ywangd ywangd added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Apr 17, 2023
@elasticsearchmachine elasticsearchmachine merged commit bbea1f1 into elastic:main Apr 17, 2023
@ywangd ywangd deleted the add-authorization-info-for-cca branch April 17, 2023 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >non-issue :Security/Security Security issues without another label Team:Security Meta label for security team v8.8.0

3 participants