Documentation
¶
Overview ¶
Package auth handles authentication and OAuth flows.
Index ¶
- Variables
- func ErrorMessage(err error) string
- func GeneratePKCE() (*pkceParams, error)
- func NewCallbackServer(ctx context.Context, path string) (*callbackServer, error)
- func NewOAuthClient(cfg *config.OAuthConfig) *oauthClient
- func OpenBrowser(ctx context.Context, urlStr string) error
- type FileStore
- func (s *FileStore) DeleteToken() error
- func (s *FileStore) LoadToken() (*Token, error)
- func (s *FileStore) LoadTokenForLogout() (*Token, error)
- func (s *FileStore) Path() string
- func (s *FileStore) PrepareLogin() error
- func (s *FileStore) SaveToken(token *Token) error
- func (s *FileStore) Source() string
- type IntrospectResponse
- type Store
- type Token
- type WritableStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrConfigMismatch = errors.New("authentication configuration mismatch") // ErrAuthRequired indicates that authentication is required. ErrAuthRequired = errors.New("authentication required") // ErrInvalidInput indicates invalid input to an auth function. ErrInvalidInput = errors.New("invalid input") )
Functions ¶
func ErrorMessage ¶
ErrorMessage removes classification sentinels from user-facing diagnostics.
func GeneratePKCE ¶
func GeneratePKCE() (*pkceParams, error)
GeneratePKCE generates new PKCE parameters for an OAuth flow.
func NewCallbackServer ¶
NewCallbackServer creates a new callback server.
func NewOAuthClient ¶
func NewOAuthClient(cfg *config.OAuthConfig) *oauthClient
NewOAuthClient creates a new OAuth client.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore stores OAuth credentials separately from ordinary configuration.
func (*FileStore) DeleteToken ¶
func (*FileStore) LoadTokenForLogout ¶
func (*FileStore) PrepareLogin ¶
PrepareLogin rejects known storage failures before browser authentication. The temporary probe does not replace existing credentials.
type IntrospectResponse ¶
type IntrospectResponse struct {
Active bool `json:"active"`
Username string `json:"username,omitempty"`
Scope string `json:"scope,omitempty"`
Exp int64 `json:"exp,omitempty"`
Iat int64 `json:"iat,omitempty"`
}
IntrospectResponse represents the token introspection response.
type Store ¶
type Store interface {
LoadToken() (*Token, error)
SaveToken(*Token) error
DeleteToken() error
Source() string
}
Store is the selected credential source. Environment credentials are read-only.
type Token ¶
type Token struct {
// External tokens have no local expiry or refresh metadata.
External bool `json:"-"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenType string `json:"token_type"`
ExpiresAt time.Time `json:"expires_at"`
Scope string `json:"scope,omitempty"`
IssuedAt time.Time `json:"issued_at"`
BaseURL string `json:"base_url"`
}
Token represents an OAuth token with expiry information.
func RequireAuthFrom ¶
RequireAuthFrom loads credentials and checks their configured destination.
func (*Token) IsExpiringSoon ¶
IsExpiringSoon checks if the token will expire within the given duration.
func (*Token) TimeUntilExpiry ¶
TimeUntilExpiry returns the duration until the token expires.
type WritableStore ¶
WritableStore supports the persistent authentication lifecycle. Logout may read an insecure regular file solely to revoke its credentials.
func NewWritableStore ¶
func NewWritableStore() (WritableStore, error)
NewWritableStore selects persistent storage without relying on display labels.