Documentation
¶
Index ¶
Constants ¶
const CommandACLSurfaceAI = "ai"
CommandACLSurfaceAI is the command_acl_surface value that sends command ACL management to the command pre-approval ledger.
Variables ¶
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
IsRefreshTokenRejected reports an OAuth refusal that requires a new login.
func RevokeToken ¶ added in v0.4.4
func RevokeToken(httpClient *http.Client, envInfo *AuthEnvResponse, refreshToken string) error
RevokeToken revokes refreshToken at the Auth0 domain envInfo names.
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
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, started config.Config) (*TokenResponse, error)
RefreshAccessToken serializes the complete grant against the login the caller loaded.