auth

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyringService = "owlctl"
	TokenEnvVar    = "OWLCTL_TOKEN"
)

Variables

This section is empty.

Functions

func ClearProcessTokenCache added in v1.2.0

func ClearProcessTokenCache()

ClearProcessTokenCache resets the in-process token cache. Used when switching instances mid-process (e.g., multi-instance group operations).

func ExtractTokenInfo

func ExtractTokenInfo(responseBody []byte, isBasicAuth bool) (string, int, error)

ExtractTokenInfo parses token from OAuth response body (for legacy compatibility)

func FormatTokenForHeaders

func FormatTokenForHeaders(token string, expiresIn int, tokenType string, isBasicAuth bool) []byte

FormatTokenForHeaders formats token for headers.json (legacy format)

func GetTokenForRequest

func GetTokenForRequest(profileName string, profile models.Profile, settings models.Settings) (string, error)

GetTokenForRequest is a convenience function for API requests that handles credential gathering from settings/env and token resolution. Returns the token string or an error.

func IsCI

func IsCI() bool

IsCI returns true if running in a CI/CD environment

Types

type AuthResult

type AuthResult struct {
	Token       string
	ExpiresIn   int
	TokenType   string
	IsBasicAuth bool
}

AuthResult contains authentication response

type Authenticator

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

Authenticator handles API authentication

func NewAuthenticator

func NewAuthenticator(insecure bool, debug bool) *Authenticator

NewAuthenticator creates a new authenticator

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(profile models.Profile, username, password, apiURL string) (*AuthResult, error)

Authenticate performs OAuth or Basic Auth login

type TokenInfo

type TokenInfo struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
	IssuedAt  time.Time `json:"issued_at"`
	Profile   string    `json:"profile"`
}

TokenInfo holds token metadata

type TokenManager

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

TokenManager handles token storage and retrieval

func NewTokenManager

func NewTokenManager(debug bool) (*TokenManager, error)

NewTokenManager creates a new token manager

func (*TokenManager) AuthenticateWithSettings

func (tm *TokenManager) AuthenticateWithSettings(profile models.Profile, username, password, apiURL string, insecure bool) (string, int, error)

AuthenticateWithSettings performs OAuth login with settings context

func (*TokenManager) DeleteToken

func (tm *TokenManager) DeleteToken(profileName string) error

DeleteToken removes a token from keychain

func (*TokenManager) GetToken

func (tm *TokenManager) GetToken(profileName string, profile models.Profile, username, password, apiURL string, insecure bool) (string, error)

GetToken retrieves token using hybrid approach Priority: 1) OWLCTL_TOKEN env var, 2) keychain, 3) auto-authenticate profileName is used for keychain storage/retrieval

func (*TokenManager) StoreToken

func (tm *TokenManager) StoreToken(profileName, token string, expiresIn int) error

StoreToken stores a token in the system keychain

Jump to

Keyboard shortcuts

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