auth0

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const CommandACLSurfaceAI = "ai"

CommandACLSurfaceAI is the command_acl_surface value that sends command ACL management to the command pre-approval ledger.

Variables

View Source
var (
	ErrDeviceCodeTimedOut = errors.New("authentication timed out. Please restart the login process")
	ErrDeviceCodeDenied   = errors.New("authentication was denied. You may have cancelled the browser prompt")
	ErrDeviceCodeExpired  = errors.New("authentication session expired. Please run 'alpacon login' again")
)

Sentinels for the device-code endings a caller may word its own remedy for; the text is what 'alpacon login' prints.

Functions

func IsRefreshTokenRejected added in v1.16.0

func IsRefreshTokenRejected(err error) bool

IsRefreshTokenRejected reports an OAuth refusal that requires a new login.

func Logout added in v0.4.4

func Logout(httpClient *http.Client, validConfig config.Config) error

func RevokeToken added in v0.4.4

func RevokeToken(httpClient *http.Client, workspaceURL string, refreshToken string) error

Types

type Auth0Config

type Auth0Config struct {
	Method   string `json:"method"`
	ClientID string `json:"client_id,omitempty"`
	Domain   string `json:"domain,omitempty"`
	Audience string `json:"audience,omitempty"`
	// SchemaName is the frozen workspace identity, equal to the Auth0 organization name; the org
	// scope prefers it over the URL label, which can change. Empty on older servers.
	SchemaName string `json:"schema_name,omitempty"`
	// WorkspaceID is the workspace's UUID, which the signer's ledger names a
	// workspace by. Empty on older servers that do not return the field.
	WorkspaceID string `json:"workspace_id,omitempty"`
}

type AuthEnvResponse

type AuthEnvResponse struct {
	Auth0    Auth0Config `json:"auth0"`
	Language string      `json:"language"`
	Surfaces Surfaces    `json:"surfaces"`
	// CommandACLSurface is CommandACLSurfaceAI when the workspace's command ACLs
	// live on the command pre-approval ledger.
	CommandACLSurface CommandACLSurface `json:"command_acl_surface"`
}

func FetchAuthEnv

func FetchAuthEnv(workspaceURL string, httpClient *http.Client) (*AuthEnvResponse, error)

type CommandACLSurface added in v1.18.0

type CommandACLSurface string

CommandACLSurface is the server's command_acl_surface answer, or "" when the server predates the key.

func (*CommandACLSurface) UnmarshalJSON added in v1.18.0

func (s *CommandACLSurface) UnmarshalJSON(data []byte) error

UnmarshalJSON never fails, for the reason Surfaces gives: anything that is not a JSON string reads as "".

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval"`
	VerificationURIComplete string `json:"verification_uri_complete"`
}

func RequestDeviceCode

func RequestDeviceCode(workspaceName string, httpClient *http.Client, envInfo *AuthEnvResponse) (*DeviceCodeResponse, error)

func RequestSignerDeviceCode added in v1.18.0

func RequestSignerDeviceCode(workspaceName string, httpClient *http.Client, envInfo *AuthEnvResponse, audience string) (*DeviceCodeResponse, error)

RequestSignerDeviceCode authorizes the signer's audience with the login's org scope but no offline_access: the signer's API grants no refresh token.

type Surfaces added in v1.15.0

type Surfaces struct {
	Kubernetes bool
}

Surfaces lists the optional product surfaces the server says this workspace exposes. A server that predates the key leaves every surface false.

func (*Surfaces) UnmarshalJSON added in v1.15.0

func (s *Surfaces) UnmarshalJSON(data []byte) error

UnmarshalJSON never fails. The same response feeds login, token refresh, revoke and logout, so a malformed surfaces value must not take those down; anything that is not a JSON object carrying a boolean reads as false.

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token,omitempty"`
	IDToken      string `json:"id_token,omitempty"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	TokenType    string `json:"token_type"`
	Error        string `json:"error,omitempty"`
	ErrorDesc    string `json:"error_description,omitempty"`
}

func PollForToken

func PollForToken(deviceCodeRes *DeviceCodeResponse, envInfo *AuthEnvResponse) (*TokenResponse, error)

func RefreshAccessToken

func RefreshAccessToken(workspaceURL string, httpClient *http.Client, refreshToken string) (*TokenResponse, error)

Jump to

Keyboard shortcuts

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