-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add auth print-access-token command
This is a convenience function to print the API client access token to stdout. Mainly useful when testing things on the API with curl and maybe some scriping use-cases.
- Loading branch information
Showing
2 changed files
with
23 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package auth | ||
|
||
type Cmd struct { | ||
Login LoginCmd `cmd:"" help:"Login to nineapis.ch."` | ||
Logout LogoutCmd `cmd:"" help:"Logout from nineapis.ch."` | ||
Cluster ClusterCmd `cmd:"" help:"Authenticate with Kubernetes Cluster."` | ||
OIDC OIDCCmd `cmd:"" help:"Perform interactive OIDC login." hidden:""` | ||
SetProject SetProjectCmd `cmd:"" help:"Set the default project to be used."` | ||
SetOrg SetOrgCmd `cmd:"" help:"Set the organization to be used."` | ||
Whoami WhoAmICmd `cmd:"" help:"Show who you are logged in as, your active organization and all your available organizations."` | ||
Login LoginCmd `cmd:"" help:"Login to nineapis.ch."` | ||
Logout LogoutCmd `cmd:"" help:"Logout from nineapis.ch."` | ||
Cluster ClusterCmd `cmd:"" help:"Authenticate with Kubernetes Cluster."` | ||
OIDC OIDCCmd `cmd:"" help:"Perform interactive OIDC login." hidden:""` | ||
SetProject SetProjectCmd `cmd:"" help:"Set the default project to be used."` | ||
SetOrg SetOrgCmd `cmd:"" help:"Set the organization to be used."` | ||
Whoami WhoAmICmd `cmd:"" help:"Show who you are logged in as, your active organization and all your available organizations."` | ||
PrintAccessToken PrintAccessTokenCmd `cmd:"" help:"Print short-lived access token to authenticate against the API to stdout and exit."` | ||
} |
This file contains 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,15 @@ | ||
package auth | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ninech/nctl/api" | ||
) | ||
|
||
type PrintAccessTokenCmd struct{} | ||
|
||
func (o *PrintAccessTokenCmd) Run(ctx context.Context, client *api.Client) error { | ||
fmt.Println(client.Token) | ||
return nil | ||
} |