-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Enforce license for cross-cluster API key APIs #96307
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| import org.elasticsearch.client.internal.node.NodeClient; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.core.TimeValue; | ||
| import org.elasticsearch.license.LicenseUtils; | ||
| import org.elasticsearch.license.XPackLicenseState; | ||
| import org.elasticsearch.rest.RestRequest; | ||
| import org.elasticsearch.rest.action.RestToXContentListener; | ||
|
|
@@ -26,6 +27,7 @@ | |
| import static org.elasticsearch.rest.RestRequest.Method.POST; | ||
| import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg; | ||
| import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg; | ||
| import static org.elasticsearch.xpack.security.Security.ADVANCED_REMOTE_CLUSTER_SECURITY_FEATURE; | ||
|
|
||
| /** | ||
| * Rest action to create an API key specific to cross cluster access via the dedicate remote cluster server port | ||
|
|
@@ -79,4 +81,16 @@ protected RestChannelConsumer innerPrepareRequest(final RestRequest request, fin | |
| new RestToXContentListener<>(channel) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| protected Exception checkFeatureAvailable(RestRequest request) { | ||
| final Exception failedFeature = super.checkFeatureAvailable(request); | ||
| if (failedFeature != null) { | ||
| return failedFeature; | ||
| } else if (ADVANCED_REMOTE_CLUSTER_SECURITY_FEATURE.checkWithoutTracking(licenseState)) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went back and forth with whether this should |
||
| return null; | ||
| } else { | ||
| return LicenseUtils.newComplianceException(ADVANCED_REMOTE_CLUSTER_SECURITY_FEATURE.getName()); | ||
| } | ||
| } | ||
|
Comment on lines
+85
to
+95
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is duplicated in RestUpdateCrossClusterApiKeyAction. If we get to add more REST APIs for cross-cluster API keys, we can extract a superclass to have this method in one place. For now I am keeping it this way. Please let me know if you think otherwise. |
||
| } | ||
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.
Need to change the initial license for FC to be trial. Otherwise the whole test suite fails because it cannot create the cross-cluster API key. Fortunately, this change does not really impact the essence of what we are trying to test here.