-
Notifications
You must be signed in to change notification settings - Fork 279
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
[Extensions] Generate auth tokens for service accounts #2716
[Extensions] Generate auth tokens for service accounts #2716
Conversation
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
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.
Request 1 change. Looks good to me otherwise.
if (Objects.requireNonNull(securityJsonNode.get("isEnabled").asString()).equalsIgnoreCase("false")) { // If the service account is not active | ||
throw new UserServiceException(AUTH_TOKEN_GENERATION_MESSAGE); | ||
if (Optional.of(securityJsonNode.get("isEnabled").asString().equalsIgnoreCase("false")).orElseThrow(() -> {throw new UserServiceException(AUTH_TOKEN_GENERATION_MESSAGE);})) { | ||
throw new UserServiceException(AUTH_TOKEN_GENERATION_MESSAGE); // If the service account is not active |
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.
orElseThrow will not be utilized here as the value will either be a boolean or it will throw an NPE stating return value of isEnabled is null
. In order to utilize orElseThrow to catch a missing isEnabled
or isService
property in SecurityJsonNode, you can make following changes:
UserServiceException e = new UserServiceException(AUTH_TOKEN_GENERATION_MESSAGE);
boolean isService = readBooleanFromJsonNode(securityJsonNode, "isService", e);
boolean isEnabled = readBooleanFromJsonNode(securityJsonNode, "isEnabled", e);
if(!isService || !isEnabled) {
throw e;
}
private boolean readBooleanFromJsonNode(SecurityJsonNode node, String key, Exception e) {
return Boolean.parseBoolean(Optional.ofNullable(node.get(key)).orElseThrow(() -> e).asText());
}
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
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 @scrawfor99 !
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <steecraw@amazon.com>
Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
e5d92df
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-2716-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1201335bd1c95fc2bb7e9b2210ffe5e029457d25
# Push it to GitHub
git push --set-upstream origin backport/backport-2716-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
…oject#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
…oject#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
…oject#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
…s, and multi tenancy changes (#2737) * [Extensions] Generate auth tokens for service accounts (#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * Security User Refactor (#2594) --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * Backport service account changes Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Update test Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Optimize imports Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Spotless Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix plugin Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix whitespace Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Fix multitency config update (#2758) Moved multi-tenancy to REST API implementation Signed-off-by: Andrey Pleskach <ples@aiven.io> * Remove SSLCertsAction Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Fix dependency Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix tenancy tests Signed-off-by: Stephen Crawford <steecraw@amazon.com> --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Signed-off-by: Andrey Pleskach <ples@aiven.io> Co-authored-by: Andrey Pleskach <ples@aiven.io>
…s, and multi tenancy changes (#2737) * [Extensions] Generate auth tokens for service accounts (#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * Security User Refactor (#2594) --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * Backport service account changes Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Update test Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Optimize imports Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Spotless Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix plugin Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix whitespace Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Fix multitency config update (#2758) Moved multi-tenancy to REST API implementation Signed-off-by: Andrey Pleskach <ples@aiven.io> * Remove SSLCertsAction Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Fix dependency Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix tenancy tests Signed-off-by: Stephen Crawford <steecraw@amazon.com> --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Signed-off-by: Andrey Pleskach <ples@aiven.io> Co-authored-by: Andrey Pleskach <ples@aiven.io> (cherry picked from commit fa33fc5)
…s, and multi tenancy changes (#2737) (#2777) * [Extensions] Generate auth tokens for service accounts (#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * Security User Refactor (#2594) --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> * Backport service account changes Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Update test Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Optimize imports Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Spotless Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix plugin Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix whitespace Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Fix multitency config update (#2758) Moved multi-tenancy to REST API implementation Signed-off-by: Andrey Pleskach <ples@aiven.io> * Remove SSLCertsAction Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Fix dependency Signed-off-by: Stephen Crawford <steecraw@amazon.com> * fix tenancy tests Signed-off-by: Stephen Crawford <steecraw@amazon.com> --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Signed-off-by: Andrey Pleskach <ples@aiven.io> Co-authored-by: Andrey Pleskach <ples@aiven.io> (cherry picked from commit fa33fc5) Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
…oject#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
…oject#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
…oject#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
…oject#2716) * Generate auth tokens for service accounts Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com> Signed-off-by: Sam <samuel.costa@eliatra.com>
Description
This is a PR to introduce the functionality for generating an auth token for an extension. The auth token consists of a an encoded basic auth token created from a randomly generated password. The token is then passed back to the client so that changes can be made in core in order to later perform authentication and authorization using the token.
Issues Resolved
This issue addresses This PR covers issue #2611 and issue #2668.
Testing
New tests are added to the UserApiTest file.
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.