-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add support for custom credential manager extensions #2230
Conversation
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2230 +/- ##
==========================================
+ Coverage 91.83% 91.90% +0.06%
==========================================
Files 90 90
Lines 9201 9242 +41
Branches 1900 1908 +8
==========================================
+ Hits 8450 8494 +44
+ Misses 750 747 -3
Partials 1 1
☔ View full report in Codecov by Sentry. |
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[email protected]>
Signed-off-by: Rudy Flores <[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.
Thanks @rudyflores for this enhancement
Would you mind adding a section in the wiki under Extenders section to explain the new addition please?
Signed-off-by: Rudy Flores <[email protected]>
@JillieBeanSim documentation written for custom credential manager support: https://github.com/zowe/vscode-extension-for-zowe/wiki/Secure-Credentials-for-Extenders#using-a-custom-credential-manager |
Signed-off-by: Rudy Flores <[email protected]>
Awesome work! Sorry for taking so long to review this PR 😢 Tested this PR by installing the K8s extension and it works 🎉 In #2212 (comment) the following implementation was suggested:
This PR implements (1) and (2), but not (3) and (4). Do we still want to implement (3) and (4), and if so would we plan to do it in this PR or a separate one? Additional Comments:
|
@t1m0thyj Regarding your comment, (1) and (2) should be implemented. As for (3) and (4), that was not really done yet since this can perhaps be addressed in a follow up PR? I think this PR is already a good starting point which we can perhaps refine to have those last two requirements implemented in order for us to provide the best experience when using custom credential managers :) |
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 awesome so far! I was able to store credentials in a secret on a Google Cloud k8s cluster. However, I ran into a couple issues when testing:
After I installed the K8s plugin in Zowe CLI, I expected that ZE would prompt me to install the K8s extension when VS Code is launched. But it didn't prompt me, and it also reset my CredentialManager setting in ~/.zowe/settings/imperative.json back to @zowe/cli.
Like @t1m0thyj mentioned, I had a similar issue to the one described above, except I already had the plugin and VS extension installed. After reloading my VS Code window, the credential manager reset to @zowe/cli
. After reinstalling both the CLI plugin and VS Code extension, the issue was resolved. Here's how I was able to reproduce the problem:
- Install Kubernetes VS Code extension
- Install Kubernetes CLI plugin in the command line
- Reload window for Zowe Explorer
- Notice that the
CredentialManager
value was reset to@zowe/cli
In addition, I also noticed that the credentials are stored under a single secret on Google Cloud, and I presume this will also be the case in a local environment. Since the credentials are stored in a way where the Zowe config path is the "key" for the object, @zFernand0 and I quickly discussed a scenario where he could potentially replace my credentials in the secret object:
- Create a path that matches the file path my credentials are stored under
- Set the
ZOWE_CLI_HOME
environment variable to fall under this path (e.g. if my config is/a/b/c/zowe.config.json
,ZOWE_CLI_HOME
would be/a/b/c
). - Right click on a session in Zowe Explorer -> "Update Credentials"
- After entering in the username and password, my stored credentials will be overwritten in the secret object w/ the new credentials provided.
Could we potentially avoid this by generating a unique hash on the user's end, and then chaining that with the file path to make a unique key? Or, could we generate a unique hash and simply use that as the key?
With either proposal, we would have to store the hash/identifier somewhere (such as in the Zowe config itself), but this would prevent someone from intentionally overwriting other user's credentials in the same cluster.
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.
Will approve once merge conflicts are resolved 🙂
I have a question about this sequence:
- User installs
Kubernetes secrets credential manager extension
imperative.json
is set toSecrets for Kubernetes
Is it correct that in between those steps, refresh is required for changes to happen? If so that's fine - I think in the future we could investigate handling the extensions.onDidChange
event in VS Code to prompt the user to refresh ZE or reload the window.
Regarding the issues mentioned earlier:
- The credential manager value in
~/.zowe/settings/imperative.json
changes back to "Secrets for Kubernetes" - this still happens for me but fixes itself after reloading the window - The possibility for the same K8s secret to be shared by multiple users - this is related to the K8s extension not ZE so created a separate issue: Document that each user should have separate namespace zowe-cli-secrets-for-kubernetes#18
moving comment to zowe/zowe-cli-secrets-for-kubernetes as it relates to the extension and not this PR |
Signed-off-by: Rudy Flores <[email protected]>
Yes that is correct, currently the user needs to restart in order to see the changes reflected. I think in the future it would be nice to find a way to prompt for a reload if a credential manager is installed/uninstalled (currently only disabling the custom credential manager prompts for reload because VS Code prompts to do so). Regarding the bullet points:
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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 @rudyflores!
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.
Thanks for addressing all my novice questions 😋
LGTM! 😋
Proposed changes
Solves #2212
Add support for custom credential manager extensions. When a new custom credential manager extension is installed, Zowe Explorer will activate that extension and handle credentials for Zowe Profiles through the custom credential manager override set in the
imperative.json
file.e.g:
Kubernetes secrets credential manager extension
imperative.json
is set toSecrets for Kubernetes
Kubernetes secrets credential manager extension
imperative.json
is set to the default@zowe/cli
Release Notes
Milestone: TBD
Changelog: Added support for custom credential manager extensions in Zowe Explorer
Types of changes
What types of changes does your code introduce to Zowe Explorer?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This checklist will be used as reference for both the contributor and the revieweryarn workspace vscode-extension-for-zowe vscode:prepublish
has been executedFurther comments
This change will also remove the old code that will default
imperative.json
back to@zowe/cli
if the unsecure profile is in use. From now onimperative.json
should reflect what plugin is installed, the default is in use, or no credential manager is needed.