Documentation
¶
Index ¶
- Constants
- Variables
- func AuthenticationErrorCode(err error) string
- func HashPassword(password string) ([]byte, error)
- func IsRateLimited(err error) bool
- func ReadPasswordHash(stateDir string) ([]byte, error)
- func RegisterTyped[TReq any, TResp any](r *sessionrpc.Router, typeID uint32, gate *Gate, meta *session.Meta, ...)
- func RequireRPC(gate *Gate, meta *session.Meta, policy RPCAccessPolicy) error
- func RetryAfter(err error) time.Duration
- func WritePasswordHash(stateDir string, hash []byte) error
- type AttemptPolicy
- type AttemptPolicyStep
- type AuthenticationRequest
- type ExpiredLocalSession
- type Gate
- func (g *Gate) AuthenticateChannel(channelID string, req AuthenticationRequest, subject string) (*UnlockResult, error)
- func (g *Gate) AuthenticateLocal(req AuthenticationRequest, subject, binding string) (*LocalSessionResult, error)
- func (g *Gate) CanResumeMeta(resumeToken string, meta session.Meta) bool
- func (g *Gate) Close() error
- func (g *Gate) DelegateCodeSpace(channelID, codeSpaceID string) (string, error)
- func (g *Gate) Enabled() bool
- func (g *Gate) IsChannelUnlocked(channelID string) bool
- func (g *Gate) IsLocalSessionValid(token string) bool
- func (g *Gate) LocalSessionExpiresAt(token string) (time.Time, bool)
- func (g *Gate) Manage(binding, label string, req SecurityRequest) (*SecurityResult, error)
- func (g *Gate) MintLocalSession(password string) (*LocalSessionResult, error)
- func (g *Gate) MintLocalSessionFromResumeToken(resumeToken string, meta session.Meta) (*LocalSessionResult, error)
- func (g *Gate) MintLocalSessionWithSubject(password, subject string) (*LocalSessionResult, error)
- func (g *Gate) RegisterChannel(meta session.Meta)
- func (g *Gate) RegisterChannelWithOptions(meta session.Meta, opts RegisterChannelOptions)
- func (g *Gate) ResolveLocalSession(token string) (string, time.Time, bool)
- func (g *Gate) ResumeChannel(channelID string, resumeToken string) error
- func (g *Gate) RevokeLocalSession(token string)
- func (g *Gate) RevokeResumeToken(resumeToken string)
- func (g *Gate) SecurityStatus() SecurityStatus
- func (g *Gate) Status(channelID string) Status
- func (g *Gate) TakeAccessSessionByResumeToken(resumeToken string) (string, bool)
- func (g *Gate) TakeExpiredLocalSessions(now time.Time) []ExpiredLocalSession
- func (g *Gate) TakeLocalSession(token string) (string, bool)
- func (g *Gate) TwoFactorEnabled() bool
- func (g *Gate) UnlockChannel(channelID string, password string) (*UnlockResult, error)
- func (g *Gate) UnlockChannelWithSubject(channelID, password, subject string) (*UnlockResult, error)
- func (g *Gate) UnregisterChannel(channelID string)
- func (g *Gate) VerifyPassword(password string) bool
- type LocalSessionResult
- type Options
- type RPCAccessPolicy
- type RateLimitError
- type RegisterChannelOptions
- type SecurityRequest
- type SecurityResult
- type SecurityStatus
- type Status
- type UnlockResult
Constants ¶
const ( DefaultResumeTTL = 12 * time.Hour DefaultLocalSessionTTL = 12 * time.Hour )
const DefaultFailedAttemptRetention = 30 * time.Minute
Variables ¶
var ErrChallengeExpired = errors.New("sign-in expired; enter your environment password again")
var ErrInvalidPassword = errors.New("invalid password")
var ErrRecoveryPending = errors.New("host recovery is pending; finish security setup on the host")
var ErrRestartRequired = errors.New("restart this Runtime to apply the saved environment password before changing security settings")
var ErrSecondFactor = errors.New("enter an authenticator code or recovery code")
Functions ¶
func AuthenticationErrorCode ¶ added in v0.13.0
func HashPassword ¶ added in v0.13.0
func IsRateLimited ¶
func ReadPasswordHash ¶ added in v0.13.0
ReadPasswordHash reads the single committed authority after migration.
func RegisterTyped ¶
func RequireRPC ¶
func RequireRPC(gate *Gate, meta *session.Meta, policy RPCAccessPolicy) error
func RetryAfter ¶
func WritePasswordHash ¶ added in v0.13.0
WritePasswordHash is called by the Runtime owner under its state lock. Clearing is explicit; an omitted startup secret never clears a saved hash.
Types ¶
type AttemptPolicy ¶
type AttemptPolicy struct {
Steps []AttemptPolicyStep
Retention time.Duration
}
type AttemptPolicyStep ¶
type AuthenticationRequest ¶ added in v0.13.0
type AuthenticationRequest struct {
Password string `json:"password,omitempty"`
Delegation string `json:"delegation,omitempty"`
ResumeToken string `json:"resume_token,omitempty"`
ChallengeID string `json:"challenge_id,omitempty"`
Code string `json:"code,omitempty"`
RecoveryCode string `json:"recovery_code,omitempty"`
}
AuthenticationRequest is shared by browser, encrypted proxy and native streams. A challenge is an authentication-only capability, never a business credential.
type ExpiredLocalSession ¶ added in v0.11.0
type ExpiredLocalSession struct {
AccessSessionID string
}
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
func NewWithPasswordHash ¶ added in v0.13.0
NewWithPasswordHash restores server-owned authentication without retaining a plaintext password. An empty hash explicitly disables the gate.
func OpenPersistent ¶ added in v0.13.0
func (*Gate) AuthenticateChannel ¶ added in v0.13.0
func (g *Gate) AuthenticateChannel(channelID string, req AuthenticationRequest, subject string) (*UnlockResult, error)
func (*Gate) AuthenticateLocal ¶ added in v0.13.0
func (g *Gate) AuthenticateLocal(req AuthenticationRequest, subject, binding string) (*LocalSessionResult, error)
func (*Gate) CanResumeMeta ¶
func (*Gate) DelegateCodeSpace ¶ added in v0.13.0
DelegateCodeSpace narrows an authenticated Env App session to one editor. The child still receives its own independently checked permission metadata.
func (*Gate) IsChannelUnlocked ¶
func (*Gate) IsLocalSessionValid ¶
func (*Gate) LocalSessionExpiresAt ¶ added in v0.11.0
LocalSessionExpiresAt resolves the active deadline for an opaque Local UI session token without exposing any other session state to callers.
func (*Gate) Manage ¶ added in v0.13.0
func (g *Gate) Manage(binding, label string, req SecurityRequest) (*SecurityResult, error)
Manage is reachable only through the authenticated private owner control service or an offline CLI holding the same environment state lock.
func (*Gate) MintLocalSession ¶
func (g *Gate) MintLocalSession(password string) (*LocalSessionResult, error)
func (*Gate) MintLocalSessionFromResumeToken ¶
func (*Gate) MintLocalSessionWithSubject ¶
func (g *Gate) MintLocalSessionWithSubject(password, subject string) (*LocalSessionResult, error)
func (*Gate) RegisterChannel ¶
func (*Gate) RegisterChannelWithOptions ¶
func (g *Gate) RegisterChannelWithOptions(meta session.Meta, opts RegisterChannelOptions)
func (*Gate) ResolveLocalSession ¶ added in v0.11.0
func (*Gate) ResumeChannel ¶
func (*Gate) RevokeLocalSession ¶
func (*Gate) RevokeResumeToken ¶
func (*Gate) SecurityStatus ¶ added in v0.13.0
func (g *Gate) SecurityStatus() SecurityStatus
func (*Gate) TakeAccessSessionByResumeToken ¶ added in v0.11.0
TakeAccessSessionByResumeToken revokes the complete access-session lineage identified by an active resume token and returns its opaque internal ID.
func (*Gate) TakeExpiredLocalSessions ¶ added in v0.11.0
func (g *Gate) TakeExpiredLocalSessions(now time.Time) []ExpiredLocalSession
func (*Gate) TakeLocalSession ¶ added in v0.11.0
func (*Gate) TwoFactorEnabled ¶ added in v0.13.0
func (*Gate) UnlockChannel ¶
func (g *Gate) UnlockChannel(channelID string, password string) (*UnlockResult, error)
func (*Gate) UnlockChannelWithSubject ¶
func (g *Gate) UnlockChannelWithSubject(channelID, password, subject string) (*UnlockResult, error)
func (*Gate) UnregisterChannel ¶
func (*Gate) VerifyPassword ¶
type LocalSessionResult ¶
type LocalSessionResult struct {
SecondFactorRequired bool `json:"second_factor_required,omitempty"`
ChallengeID string `json:"challenge_id,omitempty"`
Unlocked bool `json:"unlocked"`
SessionToken string `json:"-"`
AccessSessionID string `json:"-"`
SessionExpiresAtUnix int64 `json:"session_expires_at_unix_ms,omitempty"`
ResumeToken string `json:"resume_token,omitempty"`
ResumeExpiresAtUnix int64 `json:"resume_expires_at_unix_ms,omitempty"`
}
type RPCAccessPolicy ¶
type RPCAccessPolicy int
const ( RPCAccessProtected RPCAccessPolicy = iota RPCAccessPublic )
type RateLimitError ¶
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type RegisterChannelOptions ¶
type SecurityRequest ¶ added in v0.13.0
type SecurityResult ¶ added in v0.13.0
type SecurityResult struct {
SecurityStatus
OperationID string `json:"operation_id,omitempty"`
Secret string `json:"secret,omitempty"`
QRImage string `json:"qr_image,omitempty"`
RecoveryCodes []string `json:"recovery_codes,omitempty"`
}
type SecurityStatus ¶ added in v0.13.0
type Status ¶
type Status struct {
PasswordRequired bool `json:"password_required"`
TwoFactorRequired bool `json:"two_factor_required"`
Unlocked bool `json:"unlocked"`
FloeApp string `json:"floe_app,omitempty"`
CodeSpaceID string `json:"code_space_id,omitempty"`
SessionKind string `json:"session_kind,omitempty"`
}
type UnlockResult ¶
type UnlockResult struct {
SecondFactorRequired bool `json:"second_factor_required,omitempty"`
ChallengeID string `json:"challenge_id,omitempty"`
Unlocked bool `json:"unlocked"`
ResumeToken string `json:"resume_token,omitempty"`
ResumeExpiresAtUnix int64 `json:"resume_expires_at_unix_ms,omitempty"`
}