-
Notifications
You must be signed in to change notification settings - Fork 285
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
Scaffolding for POST/DELETE/GET api tokens calls #4921
Scaffolding for POST/DELETE/GET api tokens calls #4921
Conversation
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
A couple of high-level comments:
|
Updated the description. The goal of this PR is to mainly have a working POC/high level scaffolding in place to interact with the underlying opensearch cluster, such as creating/getting/deleting documents in an opensearch index representing API tokens. This PR does not finalize/use those documents to perform any authc/z checks yet.
Yes, I am working on that now, and I will add those before this PR is merged.
Yup - I am pushing a commit to address this. My high level approach will be to ask for user input for cluster permissions and index permissions (the same input when creating a role in the first place) and then performing authz checks on the ephemeral role, which will be created from these cluster/index permissions but not persisted to the index. Let me know if this high level approach makes sense to you CC @DarshitChanpura |
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
src/main/java/org/opensearch/security/action/apitokens/ApiToken.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/action/apitokens/ApiTokenIndexHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/action/apitokens/ApiTokenIndexHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/action/apitokens/ApiTokenIndexHandler.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.
This is a good base to continue working off of! Good start to this much requested feature :). It would be great to see an end-to-end integ test where a user can request a token is created and then use it to make requests against the cluster.
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
src/main/java/org/opensearch/security/action/apitokens/ApiTokenRepository.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/action/apitokens/ApiTokenIndexHandler.java
Show resolved
Hide resolved
Signed-off-by: Derek Ho <[email protected]>
src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/compliance/ComplianceConfig.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
public void deleteApiToken(String name) throws ApiTokenException { | ||
apiTokenIndexHandler.createApiTokenIndexIfAbsent(); |
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.
why do we delete token if Index doesn't exist?
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 have logic handling the delete of the api token if it doesn't exist. My thinking around creating the index here is that if users are trying to call on the delete of this endpoint in the first place they may be interested in this feature, so we create the index for them (even if the token doesn't exist). Again this can be changed in future/if index is created on bootstrap, but we can re visit this when we decide on the correct approach for index creation.
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.
We should not be creating an index. Instead we can modify the method definition to throw an exception when Index is not found.
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.
Same for below.
src/main/java/org/opensearch/security/action/apitokens/ApiTokenRepository.java
Show resolved
Hide resolved
src/main/java/org/opensearch/security/action/apitokens/ApiTokenAction.java
Show resolved
Hide resolved
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
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.
Final few comments. Looks ready to be merged otherwsie. Thanks @derek-ho !
src/main/java/org/opensearch/security/action/apitokens/ApiToken.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/action/apitokens/ApiTokenAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/action/apitokens/ApiTokenIndexHandler.java
Show resolved
Hide resolved
} | ||
|
||
public void deleteApiToken(String name) throws ApiTokenException { | ||
apiTokenIndexHandler.createApiTokenIndexIfAbsent(); |
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.
We should not be creating an index. Instead we can modify the method definition to throw an exception when Index is not found.
} | ||
|
||
public void deleteApiToken(String name) throws ApiTokenException { | ||
apiTokenIndexHandler.createApiTokenIndexIfAbsent(); |
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.
Same for below.
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
3177c34
into
opensearch-project:feature/api-tokens
Description
This PR puts the high level scaffolding in place to handle GET/POST/DELETE api tokens api calls.
Notably:
This PR is not a finalized/api token structure may be subject to change up until merge into main branch (this is designated for feature branch), and does not perform any authc/authz checks using these newly introduced API tokens.
Issues Resolved
[List any issues this PR will resolve]
Is this a backport? If so, please add backport PR # and/or commits #, and remove
backport-failed
label from the original PR.Do these changes introduce new permission(s) to be displayed in the static dropdown on the front-end? If so, please open a draft PR in the security dashboards plugin and link the draft PR here
Testing
[Please provide details of testing done: unit testing, integration testing and manual testing]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.