-
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
[Enterprise Search] Add .connector-secrets
system index and GET/POST requests
#103683
[Enterprise Search] Add .connector-secrets
system index and GET/POST requests
#103683
Conversation
.connector-secrets
system index and GET request
e2bfb5a
to
50a4c1d
Compare
.connector-secrets
system index and GET request.connector-secrets
system index and GET/POST requests
.connector-secrets
system index and GET/POST requests.connector-secrets
system index and GET/POST requests
Pinging @elastic/ent-search-eng (Team:Enterprise Search) |
@@ -38,6 +38,13 @@ dependencies { | |||
module ':modules:search-business-rules' | |||
} | |||
|
|||
testClusters.configureEach { | |||
testDistribution = 'DEFAULT' |
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.
@breskeby we should think about making it simpler to setup clusters that require security w/o having to use the default distribution. I suspect the vast majority of tests that use the default distro is for this reason alone.
Otherwise these changes LGTM.
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 looks great! A couple of questions and notes.
The only other thing that I'd request before merging is adding unit tests extending AbstractBWCSerializationTestCase
for your request and response objects. After that I'm ready to 👍. Thank you!
...src/main/java/org/elasticsearch/xpack/application/connector/secrets/SecretsIndexService.java
Outdated
Show resolved
Hide resolved
...va/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java
Outdated
Show resolved
Hide resolved
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.
Really nice work and congrats on your (I think) first PR in ES 👏 And thank you for the detailed PR description!
Left some minor comments, which are non-blocking and having one question: Do you plan to add the Backwards compatibility tests, index service tests and other unit tests, too?
...a/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/500_connector_secret_post.yml
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/application/connector/secrets/SecretsIndexService.java
Outdated
Show resolved
Hide resolved
.../main/java/org/elasticsearch/xpack/application/connector/secrets/action/GetSecretAction.java
Outdated
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/application/connector/secrets/action/GetSecretResponse.java
Outdated
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/application/connector/secrets/action/PostSecretResponse.java
Outdated
Show resolved
Hide resolved
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.
Great work! 🚀 Left some minor comments
...qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/510_connector_secret_get.yml
Outdated
Show resolved
Hide resolved
...qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/510_connector_secret_get.yml
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/application/connector/secrets/action/RestGetSecretAction.java
Outdated
Show resolved
Hide resolved
...main/java/org/elasticsearch/xpack/application/connector/secrets/action/GetSecretRequest.java
Outdated
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/application/connector/secrets/action/PostSecretRequest.java
Outdated
Show resolved
Hide resolved
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.
One additional question around endpoint naming 🙏
.../java/org/elasticsearch/xpack/application/connector/secrets/action/RestPostSecretAction.java
Outdated
Show resolved
Hide resolved
rest-api-spec/src/main/resources/rest-api-spec/api/connector_secret.get.json
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilegeResolver.java
Show resolved
Hide resolved
...arch/src/main/java/org/elasticsearch/xpack/application/connector/secrets/SecretsFeature.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/application/connector/secrets/SecretsIndexService.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/application/connector/secrets/SecretsIndexService.java
Outdated
Show resolved
Hide resolved
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.
Not for this PR, but we should consider creating separate directories for each Ent Search feature - this is becoming crowded
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.
++
...qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/510_connector_secret_get.yml
Show resolved
Hide resolved
...ck/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/EnterpriseSearch.java
Outdated
Show resolved
Hide resolved
.../org/elasticsearch/xpack/application/connector/secrets/action/TransportPostSecretAction.java
Outdated
Show resolved
Hide resolved
...ity/src/main/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccounts.java
Outdated
Show resolved
Hide resolved
...ity/src/main/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccounts.java
Outdated
Show resolved
Hide resolved
...ity/src/main/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccounts.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java
Outdated
Show resolved
Hide resolved
...va/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java
Outdated
Show resolved
Hide resolved
b000f57
to
49f571e
Compare
659d1c2
to
a0b59c8
Compare
@timgrein I've added BWC and index service tests. Let me know if there are more tests I should add. |
...va/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java
Outdated
Show resolved
Hide resolved
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. Thanks for iterating on this! 🚀
… GET/POST requests (elastic#103683)" This reverts commit b4345d9.
…T requests (elastic#103683) - Introduce new internal system index called .connector-secrets - Add GET and POST requests for connector secrets - Create read_connector_secrets and write_connector_secrets role permissions
… GET/POST requests (elastic#103683)" (elastic#104760) This reverts commit b4345d9.
Context
The Search team is currently implementing BYOI (Bring Your Own Index) for Connectors. This feature will allow users to create search indices for Connectors without having
search-
prefix the index name.Native Connectors are run using the Enterprise Search system account, which has access to search indices because it can access all indices that follow the pattern
search-*
. To continue allowing Native Connectors to function after removing the prefix requirement, we need to switch to using API keys to manage index access. That brings us to this PR.The goal of this PR is to have a place where Native Connectors can store API keys (secrets storage). A connector secret can be stored from either Kibana or the Connectors CLI. Kibana would only have write access to this index so it cannot expose secrets in the UI. Enterprise Search (which runs the Connectors CLI on cloud) will have both read and write access.
These changes follow the implementation design of Fleet's secrets storage (example PR). The implementation is largely identical, with a change in namespace.
Changes
.connector-secrets
. This will be used to store the API keys that Native Connectors will use..connector-secrets
.connector-secrets
Not included
How to test this PR
The API endpoints can be tested in Kibana Dev Tools:
Run ES from source with
./gradlew run
.Once ES is running, change the default password for the elastic user from "password" to "changeme" to match Kibana's:
Run Kibana with
yarn start
.Log into Kibana and go to
/app/dev_tools#/console
.Create a secret:
This should succeed and return the id of the created secret doc, e.g.:
Copy the id and try to get the secret:
This should succeed and return the secret id and value:
Try to get a different secret using a random value. It should fail with 404 and return an error.