auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(ctx context.Context, clientId, clientSecret, redirectUrl, authEndpoint, redirectPort, consoleUrl, workspaceId string) (*oauth2.Token, error)

func CheckTokenExpiry added in v0.2.1

func CheckTokenExpiry(token *oauth2.Token) error

func ClearTokens

func ClearTokens() error

ClearTokens removes all stored tokens

func ClearWorkspace added in v0.13.0

func ClearWorkspace() error

ClearWorkspace removes the stored workspace

func LoadToken

func LoadToken(provider string) (*oauth2.Token, error)

LoadToken loads token information from disk

func OpenBrowser

func OpenBrowser(url string) error

func SaveToken

func SaveToken(token *oauth2.Token, provider string) error

SaveToken saves the token information to disk

func SaveWorkspace added in v0.13.0

func SaveWorkspace(workspace WorkspaceInfo) error

SaveWorkspace saves the selected workspace to disk

func SelectTenant added in v0.15.0

func SelectTenant(tenants []string) (string, error)

SelectTenant prompts the user to select a tenant from a list

Types

type AuthError

type AuthError struct {
	Code    ErrorCode
	Message string
	Cause   error
}

AuthError represents authentication-related errors

func NewAuthError

func NewAuthError(code ErrorCode, message string) *AuthError

func NewAuthErrorWithCause

func NewAuthErrorWithCause(code ErrorCode, message string, cause error) *AuthError

func (*AuthError) Error

func (e *AuthError) Error() string

type AuthResult

type AuthResult struct {
	Token *Token
	Error error
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(authendpoint, clientID, clientSecret, redirectURL string) *Client

type ErrorCode

type ErrorCode int
const (
	ErrUnsupportedProvider ErrorCode = iota
	ErrTokenStorage
	ErrAuthFlow
	ErrTokenExpired
	ErrInvalidToken
	ErrNetworkError
)

type Token

type Token struct {
	AccessToken  string
	RefreshToken string
	Expiry       time.Time
}

type TokenInfo

type TokenInfo struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	IDToken      string    `json:"id_token,omitempty"`
	TokenType    string    `json:"token_type"`
	ExpiresAt    time.Time `json:"expires_at"`
	ExpiresIn    int64     `json:"expires_in,omitempty"`
	Scopes       []string  `json:"scopes"`
	Provider     string    `json:"provider"`
}

type WorkspaceInfo added in v0.13.0

type WorkspaceInfo struct {
	ID           string `json:"id"`
	Description  string `json:"description"`
	PlatformUrl  string `json:"platformUrl"`  // Track which platform this workspace belongs to
	AuthEndpoint string `json:"authEndpoint"` // Track which auth endpoint this workspace belongs to
	Tenant       string `json:"tenant"`       // The tenant name (e.g., "demo")
}

WorkspaceInfo stores the selected workspace details

func LoadWorkspace added in v0.13.0

func LoadWorkspace(currentPlatformUrl, currentAuthEndpoint string) (*WorkspaceInfo, error)

LoadWorkspace loads the selected workspace from disk and validates it matches the current platform and auth endpoint

func SelectWorkspace added in v0.13.0

func SelectWorkspace(workspaces []WorkspaceInfo) (*WorkspaceInfo, error)

SelectWorkspace prompts the user to select a workspace from a list

Jump to

Keyboard shortcuts

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