-
Notifications
You must be signed in to change notification settings - Fork 49
Creates yaml client config #143
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
Conversation
Would you consider something similar to what I proposed for the server config. A single file per provider with It would make it easy to add and remove providers rather than having to edit the client config file. |
@markafarrell Currently I'm leaning toward having one client config file on the client and a directory on the server, but I want to understand your usecase for having a directory on the client. It is important to get this right today. My current thoughts are as follows (apologies for the wall of text):
Most of these problems are not an issue on the server and fault isolation on the server is much more important. |
Signed-off-by: Ethan Heilman <[email protected]>
To address:
I was thinking we could do something like: Add a new provideropkssh provider add google \
--issuer=https://accounts.google.com \
--client_id=206584157355-7cbe4s640tvm7naoludob4ut1emii7sf.apps.googleusercontent.com \
--client_secret=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 \
--scopes="openid email profile" \
--access_type=offline \
--prompt=consent \
--redirect_uri=http://localhost:3000/login-callback \
--redirect-uri=http://localhost:10001/login-callback \
--redirect-uri=http://localhost:11110/login-callback This creates or replaces google:
issuer: https://accounts.google.com
client_id: 206584157355-7cbe4s640tvm7naoludob4ut1emii7sf.apps.googleusercontent.com
client_secret: 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
scopes: openid email profile
access_type: offline
prompt: consent
redirect_uris:
- http://localhost:3000/login-callback
- http://localhost:10001/login-callback
- http://localhost:11110/login-callback Remove provideropkssh provider delete google This removes the file Edit provideropkssh provider edit google This opens Modify provideropkssh provider edit google --set scopes="openid email" This modifies Having the primary method of interacting with the provider config be |
Another feature I think would be really nice would be an
This would essentially enable you to test with the client ONLY if a login would work. This would only be possible if we kept the provider config for server and client the same |
@markafarrell Would love to see a
This makes sense on the server because errors are expensive and bad but the client the user just opkssh login and should get a useful error message. Typing out a giant command like that is much more likely to result in an error. Opening the yaml file and editing the yaml is a better experience.
|
My 2c, I think opkssh users will be okay with a providers.d folder, this also makes it play nice(r) with MDM solutions that would allow MDM users to distribute their opkssh providers config to users centrally, which makes for nice ergonomics in enterprise settings. google:
issuer: https://accounts.google.com
client_id: 206584157355-7cbe4s640tvm7naoludob4ut1emii7sf.apps.googleusercontent.com
client_secret: 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 or okta:
issuer: https://subdomain.okta.com
client_secret: 03015ee2ff6e17d61546e061b440eebb
scopes: openid email profile groups One small source of confusion would be the name of the file vs the entry in the yaml. |
@yonatan-sevenai I'm open to adding a providers.d on the client at a point in the future, but right now want things to be as simple as possible. Having the providers in the client config does not lock out a providers.d strategy since we can always just have the providers.d extend the providers in the client config allowing backwards compatibility. |
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.
Pull Request Overview
This PR adds a YAML-based client configuration mechanism and integrates it into the login flow while introducing flags to optionally create the default config file automatically.
- Introduces new flags (config-path and create-config) and updates login command behavior to load or create a config file.
- Refactors provider configuration parsing, loading defaults, and error handling for duplicate/provider alias issues.
- Adds comprehensive tests for client configuration and provider config parsing.
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
main_test.go | Updated expected error messages in output diff. |
main.go | Introduced new flags for config path and creation of a default config. |
commands/login.go | Updated login flow to load or create a YAML client config file. |
commands/login_test.go | Updated tests to use the new config parameters and updated chooser output. |
commands/client-config/* | New implementation and tests for provider config parsing and client config. |
Files not reviewed (1)
- go.mod: Language not supported
Co-authored-by: Copilot <[email protected]> Signed-off-by: Ethan Heilman <[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.
Pull Request Overview
This PR introduces a YAML client configuration mechanism for opkssh and integrates it into the login command. Key changes include:
- Adding flags for specifying the config path and auto-creating the config file.
- Implementing functions to parse, validate, and load the client config file as well as provider configurations.
- Updating tests and documentation to reflect the new config file usage.
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
main.go, commands/login.go | Updated login command to support config file path and creation via new flags. |
commands/client-config/* | New code to parse and validate YAML config and provider configurations. |
main_test.go, login_test.go | Updated tests to match new configuration-based provider initialization. |
README.md | Updated documentation to include instructions on using the new client config file. |
Files not reviewed (1)
- go.mod: Language not supported
Comments suppressed due to low confidence (1)
README.md:127
- The documentation contains a typo. It should read 'can be configured' instead of 'can configured'.
This alias to provider mapping can configured using the OPKSSH_PROVIDERS environment variables.
Co-authored-by: Copilot <[email protected]> Signed-off-by: Ethan Heilman <[email protected]>
Creates a yaml config file for the opkssh client which lives at
~/.opk/config.yml
.You can create it by running
opkssh login --create-config
.Design
Format
There is a set of default values allowing the config to be shorter unless those values are needed - suggested by @yonatan-sevenai
When we wish to add new types of providers such as workflow providers like github actions and gitlab-ci they will have their own provider list.
Why not XDG Basedir
I had originally planned to XDG Basedir standard for config files as provided by https://pkg.go.dev/os#UserConfigDir for XDG Basedir and proposed in #94
I opted not to use XDG Basedir for the config. Instead using
~/.opk/config.yml
for all OSes. My reasons are as follows:XDG Basedir Config uses a different path for each OS
Windows:
~\AppData\Roaming\.opk\config.yml
OSX:
~/Library/Application\ Support/.opk/config.yml
Linux:
~/.config/.opk/config.yml
This means that anytime I am debugging an issue with a user I will need to first determine what OS they are running. Additionally this longer path means they will likely type it wrong when trying to find the config. This is especially true with OSX where the path as an space in it!!! Nothing makes debugging worse than having to ensure that someone escapes a space in a path
This config file should be easily found and edited by the user
XDG Basedir Config is a long path which is hard to type correctly and hard to remember. Is it
~\AppData\Local
or~\AppData\Roaming
? On windows and OSX it isn't very discoverable.No one respects XDG Basedir Config (a standard that isn't standard)
On windows, microsoft's vscode uses
~\.vscode
not~\AppData\Roaming\.vscode
, microsofts dotnet uses~\.dotnet
. Microsoft does not even follow the XDG basedir config path that microsoft choose.On OSX there is a similar pattern
~/.rustup
~/.cargo
~/.gitconfig
~/.nvm
~/.npm
~/.vscode
~/.bashrc
~/go
(when installed by brew)Open questions
Should we automatically create the config on first login?
I had originally been against this idea, but given time I've come around to it. This PR allows a user to create a config by typing
opkssh login --create-config
but it does not automatically create the config.TODOs
Deferred TODOs
Tests
Added many unittests to lock down this feature. Also manually tested the config, by editing it and seeing behavior change.