Documentation
¶
Index ¶
- Constants
- func CreateConfig(...) error
- func DeleteConfig() error
- func GetActiveWorkSession() (string, error)
- func GetAuthMethod(cfg Config) string
- func GetOrCreateDeviceID() (string, error)
- func GetSmuxConfig() *smux.Config
- func IsSaaS() (bool, error)
- func IsServiceToken(token string) bool
- func IsValidDeviceID(id string) bool
- func ResolveAuthMethod() string
- func SaveRefreshedAuth0Token(accessToken string, expiresIn int) error
- func SetActiveWorkSession(uuid string) error
- func SwitchWorkspace(newURL, newName string) error
- type Config
Constants ¶
const ( ConfigFileName = "config.json" ConfigFileDir = ".alpacon" // ServiceTokenPrefix is the default service-token key prefix, hard-coded here. // It matches the server's default SERVICE_TOKEN_PREFIX; if a self-hosted server // overrides that setting, its service tokens will not match this prefix and are // treated as generic tokens. Personal API tokens use "alpat-". ServiceTokenPrefix = "alpst-" )
const ( // DeviceIDFileName holds the per-installation device identifier. It sits // beside config.json rather than inside it so it is independent of session // state: logout deletes config.json, and the machine has not changed, so the // identifier must outlive it. This mirrors the web client, which keeps its // own identifier in localStorage rather than alongside its session. DeviceIDFileName = "device_id" )
Variables ¶
This section is empty.
Functions ¶
func CreateConfig ¶
func DeleteConfig ¶
func DeleteConfig() error
func GetActiveWorkSession ¶ added in v1.4.6
GetActiveWorkSession returns the active work-session UUID for the current workspace. Returns "" (no error) when no session is set, the config is missing the map, or no config file exists.
func GetAuthMethod ¶ added in v1.4.8
GetAuthMethod returns a human-readable authentication method string for cfg.
func GetOrCreateDeviceID ¶ added in v1.11.0
GetOrCreateDeviceID returns the stable per-installation device identifier, generating and persisting a new one when the file is missing or holds a malformed value. The identifier lets the server bind an MFA presence proof to the CLI installation that requested the challenge; without it the server has to fall back to an IP-based fingerprint, which two installations behind one egress IP would share.
It lives in ~/.alpacon/device_id, one line of plain text. That file is per installation rather than per workspace, so every workspace this installation logs in to shares the identifier, and it is untouched by DeleteConfig, so a logout does not orphan the presence proofs bound to it.
The identifier is not a secret in the sense a password or a token is—knowing it grants nothing to someone who cannot also authenticate as the user—but it is not inert either. Under ADR 0054 it is the value an MFA presence proof binds to, and it identifies this installation to the identity provider, travelling there in OAuth requests where it may be recorded in tenant logs. So it is a stable, security-relevant identifier rather than a throwaway: the file is kept at deviceIDFileMode inside the 0700 config directory, out of reach of other accounts on a shared machine, and it does not belong in logs or bug reports.
func GetSmuxConfig ¶ added in v1.0.0
GetSmuxConfig returns a ready-to-use smux configuration.
func IsSaaS ¶ added in v1.4.2
IsSaaS returns true if the workspace is an Alpacon Cloud (SaaS) deployment authenticated via Auth0. OnPrem deployments use a legacy API token and return false.
func IsServiceToken ¶ added in v1.7.4
IsServiceToken reports whether token is a service token, identified by its key prefix. Service tokens are application principals and have no user profile.
func IsValidDeviceID ¶ added in v1.11.0
IsValidDeviceID reports whether id is acceptable as a device identifier, applying the same rule as the Auth0 action that consumes it.
func ResolveAuthMethod ¶ added in v1.4.8
func ResolveAuthMethod() string
ResolveAuthMethod loads config and returns the auth method string.
func SaveRefreshedAuth0Token ¶
func SetActiveWorkSession ¶ added in v1.4.6
SetActiveWorkSession persists the work-session UUID for the current workspace. Pass "" to clear the entry for the current workspace.
func SwitchWorkspace ¶ added in v1.1.0
SwitchWorkspace updates the workspace URL and name in the existing config.
Types ¶
type Config ¶
type Config struct {
WorkspaceURL string `json:"workspace_url"`
WorkspaceName string `json:"workspace_name"`
Token string `json:"token,omitempty"`
ExpiresAt string `json:"expires_at,omitempty"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
AccessTokenExpiresAt string `json:"access_token_expires_at,omitempty"`
BaseDomain string `json:"base_domain,omitempty"`
Insecure bool `json:"insecure"`
// ActiveWorkSessions maps workspace name to active work-session UUID.
// Nil (not an empty map) when the key is absent from the JSON config file.
ActiveWorkSessions map[string]string `json:"active_work_sessions,omitempty"`
}
Config describes the configuration for Alpacon CLI
func LoadConfig ¶
func (Config) IsMultiWorkspaceMode ¶ added in v1.1.0
IsMultiWorkspaceMode returns true if the user logged in via Auth0 with a known base domain, enabling workspace listing and switching from the JWT.