-
Notifications
You must be signed in to change notification settings - Fork 7
feat(core): auth code PKCE flow #144
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
afede37
feat(core): add scaffolding and POC for auth code flow
jakedoublev d0ca75f
clarify manual process
jakedoublev 7a22cd9
clarify comments
jakedoublev 4834740
clarify comments
jakedoublev d9d32c6
Merge branch 'main' into feat/auth-code
jakedoublev 2d17396
WIP
jakedoublev 8ae8d55
use zitadel oidc lib for login pkce
jakedoublev 72d9e7e
Merge branch 'main' into feat/auth-code
jakedoublev 10a46fd
WIP
jakedoublev 2192cee
leave off ready to set to keyring
jakedoublev 51a4a72
get latest SDK
jakedoublev 5cb8aba
allow alternate client id
jakedoublev 1de9ede
docs
jakedoublev 8f73508
use printer
jakedoublev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/opentdf/otdfctl/pkg/cli" | ||
| "github.com/opentdf/otdfctl/pkg/handlers" | ||
| "github.com/opentdf/otdfctl/pkg/man" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func auth_codeLogin(cmd *cobra.Command, args []string) { | ||
| flagHelper := cli.NewFlagHelper(cmd) | ||
| host := flagHelper.GetRequiredString("host") | ||
| tlsNoVerify := flagHelper.GetOptionalBool("tls-no-verify") | ||
|
|
||
| tok, err := handlers.LoginWithPKCE(host, tlsNoVerify, noCacheCreds) | ||
| if err != nil { | ||
| cli.ExitWithError("could not authenticate", err) | ||
| } | ||
| if noCacheCreds { | ||
| fmt.Print(tok.AccessToken) | ||
| return | ||
| } | ||
| fmt.Println(cli.SuccessMessage("Successfully logged in with auth code PKCE flow. Credentials cached on native OS.")) | ||
| } | ||
|
|
||
| var codeLoginCmd *man.Doc | ||
|
|
||
| func init() { | ||
| codeLoginCmd = man.Docs.GetCommand("auth/code-login", | ||
| man.WithRun(auth_codeLogin), | ||
| ) | ||
| codeLoginCmd.Flags().StringP( | ||
| codeLoginCmd.GetDocFlag("client-id").Name, | ||
| codeLoginCmd.GetDocFlag("client-id").Shorthand, | ||
| codeLoginCmd.GetDocFlag("client-id").Default, | ||
| codeLoginCmd.GetDocFlag("client-id").Description, | ||
| ) | ||
| codeLoginCmd.Flags().BoolVarP( | ||
| &noCacheCreds, | ||
| codeLoginCmd.GetDocFlag("no-cache").Name, | ||
| codeLoginCmd.GetDocFlag("no-cache").Shorthand, | ||
| codeLoginCmd.GetDocFlag("no-cache").DefaultAsBool(), | ||
| codeLoginCmd.GetDocFlag("no-cache").Description, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| title: Open a browser and login with Auth Code PKCE | ||
|
|
||
| command: | ||
| name: code-login | ||
| flags: | ||
| - name: client-id | ||
| description: A clientId for use in auth code flow | ||
| shorthand: i | ||
| default: opentdf-public | ||
| required: true | ||
| - name: no-cache | ||
| description: Do not cache credentials on the native OS (print access token to stdout) | ||
| default: false | ||
| --- | ||
|
|
||
| Authenticate for use of the OpenTDF Platform through a browser (required). | ||
|
|
||
| Provide a specific public 'client-id' known to support the Auth Code PKCE flow and recognized | ||
| by the OpenTDF Platform, or use the default `opentdf-public` client if not specified. | ||
|
|
||
| The OIDC Access Token will be stored in the OS-specific keychain by default, otherwise printed to `stdout` if `--no-cache` is passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.