auth

package
v0.26.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2025 License: BSD-3-Clause-Clear Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccessTokenExpired         = errors.New("access token expired")
	ErrAccessTokenNotFound        = errors.New("no access token found")
	ErrClientCredentialsNotFound  = errors.New("client credentials not found")
	ErrInvalidAuthType            = errors.New("invalid auth type")
	ErrUnauthenticated            = errors.New("not logged in")
	ErrParsingAccessToken         = errors.New("failed to parse access token")
	ErrProfileCredentialsNotFound = errors.New("profile missing credentials")
)

Functions

func GetFreePort added in v0.22.0

func GetFreePort() (int, error)

GetFreePort returns an available TCP port on localhost. The function works by asking the operating system to assign a free port (by using port 0), then returns that assigned port.

func GetSDKAuthOptionFromProfile

func GetSDKAuthOptionFromProfile(profile *profiles.ProfileStore) (sdk.Option, error)

func GetTokenWithClientCreds

func GetTokenWithClientCreds(ctx context.Context, endpoint string, clientId string, clientSecret string, tlsNoVerify bool) (*oauth2.Token, error)

Uses the OAuth2 client credentials flow to obtain a token.

func GetTokenWithProfile

func GetTokenWithProfile(ctx context.Context, profile *profiles.ProfileStore) (*oauth2.Token, error)

func Login

func Login(ctx context.Context, platformEndpoint, tokenURL, authURL, publicClientID, authCodeFlowPort string) (*oauth2.Token, error)

Facilitates an auth code PKCE flow to obtain OIDC tokens. Spawns a local server to handle the callback and opens a browser window in each respective OS.

func LoginWithPKCE

func LoginWithPKCE(ctx context.Context, host, clientID string, tlsNoVerify bool, port string) (*oauth2.Token, error)

Logs in using the auth code PKCE flow driven by the platform well-known idP OIDC configuration.

func RevokeAccessToken

func RevokeAccessToken(ctx context.Context, endpoint, clientID, refreshToken string, tlsNoVerify bool) error

Revokes the access token

func ValidateProfileAuthCredentials

func ValidateProfileAuthCredentials(ctx context.Context, profile *profiles.ProfileStore) error

Types

type ClientCredentials

type ClientCredentials struct {
	ClientId     string `json:"clientId"`
	ClientSecret string `json:"clientSecret"`
}

func GetClientCredsFromFile

func GetClientCredsFromFile(filepath string) (ClientCredentials, error)

Retrieves credentials by reading specified file

func GetClientCredsFromJSON

func GetClientCredsFromJSON(credsJSON []byte) (ClientCredentials, error)

Parse the JSON and return the client ID and secret

type JWTClaims added in v0.16.0

type JWTClaims struct {
	Expiration int64 `json:"exp"`
}

func ParseClaimsJWT added in v0.16.0

func ParseClaimsJWT(accessToken string) (JWTClaims, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL