Documentation
¶
Overview ¶
Package auth provides commands for authentication and session management.
Index ¶
- Constants
- func KubeconfigClientSecretLogin(exec *clientcmdapi.ExecConfig, apiURL, organization string) (login string, ok bool)
- func LoginKongVars() kong.Vars
- type API
- type ClientCredentialsCmd
- type ClusterCmd
- type Cmd
- type LoginCmd
- type LogoutCmd
- type OIDCCmd
- type PrintAccessTokenCmd
- type SetOrgCmd
- type SetProjectCmd
- type WhoAmICmd
Constants ¶
const ClientCredentialsCmdName = api.ClientCredentialsCmdName
const CmdName = api.AuthCmdName
const ErrNonInteractiveEnvironmentEmptyToken = "a static API token is required in non-interactive environments"
const OIDCCmdName = api.OIDCCmdName
Variables ¶
This section is empty.
Functions ¶
func KubeconfigClientSecretLogin ¶ added in v1.22.0
func KubeconfigClientSecretLogin(exec *clientcmdapi.ExecConfig, apiURL, organization string) (login string, ok bool)
KubeconfigClientSecretLogin returns the login that moves the client secret, which kubeconfigs written by earlier versions pass to the exec plugin exec as an argument, to the keyring of the operating system. ok is false if exec does not carry a client secret. apiURL and organization are those of the kubeconfig context; an empty organization is left out. The command shows a placeholder instead of the secret, so it can be printed.
func LoginKongVars ¶
LoginKongVars returns all variables which are used in the login command
Types ¶
type API ¶
type API struct {
URL string `help:"URL of the Nine API." default:"https://nineapis.ch" env:"NCTL_API_URL" hidden:""`
Token string `` /* 136-byte string literal not displayed */
ClientID string `help:"Use an API client ID to login. Requires the --organization to also be set." env:"NCTL_API_CLIENT_ID"`
ClientSecret string `` /* 165-byte string literal not displayed */
TokenURL string `help:"Override the default client token URL." hidden:"" default:"${token_url}" env:"NCTL_API_TOKEN_URL"`
}
func (*API) Oauth2Token ¶
Oauth2Token obtains a token for a.ClientID and clientSecret.
type ClientCredentialsCmd ¶
type ClientCredentialsCmd struct {
API `embed:""`
InsecureStorage bool `help:"Read the client secret from a plain text file instead of the keyring of the operating system."`
}
func (*ClientCredentialsCmd) Run ¶
func (c *ClientCredentialsCmd) Run(ctx context.Context, creds api.Credentials) error
Run prints the token of the client-credentials exec plugin. Unless --client-secret is set, it uses the client secret stored in creds by the login.
type ClusterCmd ¶
type Cmd ¶
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:""`
ClientCredentials ClientCredentialsCmd `cmd:"" help:"Perform APIServiceAccount client-credentials 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."`
}
type LoginCmd ¶
type LoginCmd struct {
format.Writer `hidden:""`
API API `embed:"" prefix:"api-"`
Organization string `help:"Name of your organization to use when providing an API client ID/secret." env:"NCTL_ORGANIZATION"`
IssuerURL string `help:"OIDC issuer URL of the API." default:"${issuer_url}" hidden:""`
ClientID string `help:"OIDC client ID of the API." default:"${client_id}" hidden:""`
InsecureStorage bool `help:"Save credentials in plain text files instead of the keyring of the operating system."`
ForceInteractiveEnvOverride bool `` /* 193-byte string literal not displayed */
// contains filtered or unexported fields
}
type LogoutCmd ¶
type LogoutCmd struct {
format.Writer `hidden:""`
APIURL string `help:"URL of the Nine API." default:"https://nineapis.ch" env:"NCTL_API_URL" name:"api-url"`
IssuerURL string `help:"OIDC issuer URL of the API." default:"https://auth.nine.ch/auth/realms/pub"`
ClientID string `help:"OIDC client ID of the API." default:"nineapis.ch-f178254"`
// contains filtered or unexported fields
}
type OIDCCmd ¶
type PrintAccessTokenCmd ¶
type SetOrgCmd ¶
type SetOrgCmd struct {
format.Writer `hidden:""`
Organization string `arg:"" help:"Name of the organization to login to." default:""`
APIURL string `help:"URL of the Nine API." default:"https://nineapis.ch" env:"NCTL_API_URL" name:"api-url"`
IssuerURL string `help:"OIDC issuer URL of the API." default:"https://auth.nine.ch/auth/realms/pub"`
ClientID string `help:"OIDC client ID of the API." default:"nineapis.ch-f178254"`
}
type SetProjectCmd ¶
type WhoAmICmd ¶
type WhoAmICmd struct {
format.Writer `hidden:""`
APIURL string `help:"URL of the Nine API." default:"https://nineapis.ch" env:"NCTL_API_URL" name:"api-url"`
IssuerURL string `help:"OIDC issuer URL of the API." default:"https://auth.nine.ch/auth/realms/pub"`
ClientID string `help:"OIDC client ID of the API." default:"nineapis.ch-f178254"`
Format string `help:"Configures output format. ${enum}" name:"output" short:"o" enum:"text,yaml,json" default:"text"`
}