Add browser-based authentication abstraction #216
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
spacectl
currently exports the profile and credential management packages, which has been helpful when developing an external tool to interact with the Spacelift GraphQL API. I could usespacectl
to authenticate, and then have my tool interoperate with thespacectl
stored credentials. However, I'd like to allow my tool to trigger authentication if a token expires. The code for this is relatively simple, but undocumented (as far as I could tell) by Spacelift.This PR pulls the browser authentication routine out of
internal/cmd/profile/login_command.go
and into a separate package which can be used externally to trigger the authentication flow. It does not depend on any specific logging or browser packages, and instead provides a programmatic interface to initiate the authentication flow, and handle the callback while allowing the package user to handle errors, logging, output, etc.I'm not sure what the appetite for this is like upstream, however I already wrote the code for my personal use, and thought it might be helpful upstream.