Documentation
¶
Index ¶
- Constants
- Variables
- func IsRateLimited(err error) bool
- 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
- type AttemptPolicy
- type AttemptPolicyStep
- type ExpiredLocalSession
- type Gate
- func (g *Gate) CanResumeMeta(resumeToken string, meta session.Meta) bool
- 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) MintLocalSession(password string) (*LocalSessionResult, error)
- func (g *Gate) MintLocalSessionFromResumeToken(resumeToken string, meta session.Meta) (*LocalSessionResult, error)
- func (g *Gate) MintLocalSessionWithSubject(password string, subject string) (*LocalSessionResult, error)
- func (g *Gate) MintTrustedLocalSession(meta session.Meta) (*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) 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) UnlockChannel(channelID string, password string) (*UnlockResult, error)
- func (g *Gate) UnlockChannelWithSubject(channelID string, password string, 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 Status
- type UnlockResult
Constants ¶
View Source
const ( DefaultResumeTTL = 12 * time.Hour DefaultLocalSessionTTL = 12 * time.Hour LocalSessionCookieName = "redeven_local_access" )
View Source
const DefaultFailedAttemptRetention = 30 * time.Minute
Variables ¶
View Source
var ErrInvalidPassword = errors.New("invalid password")
Functions ¶
func IsRateLimited ¶
func RegisterTyped ¶
func RequireRPC ¶
func RequireRPC(gate *Gate, meta *session.Meta, policy RPCAccessPolicy) error
func RetryAfter ¶
Types ¶
type AttemptPolicy ¶
type AttemptPolicy struct {
Steps []AttemptPolicyStep
Retention time.Duration
}
type AttemptPolicyStep ¶
type ExpiredLocalSession ¶ added in v0.11.0
type ExpiredLocalSession struct {
AccessSessionID string
}
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
func (*Gate) CanResumeMeta ¶
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) MintLocalSession ¶
func (g *Gate) MintLocalSession(password string) (*LocalSessionResult, error)
func (*Gate) MintLocalSessionFromResumeToken ¶
func (*Gate) MintLocalSessionWithSubject ¶
func (g *Gate) MintLocalSessionWithSubject(password string, subject string) (*LocalSessionResult, error)
func (*Gate) MintTrustedLocalSession ¶ added in v0.7.1
func (g *Gate) MintTrustedLocalSession(meta session.Meta) (*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) 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) UnlockChannel ¶
func (g *Gate) UnlockChannel(channelID string, password string) (*UnlockResult, error)
func (*Gate) UnlockChannelWithSubject ¶
func (*Gate) UnregisterChannel ¶
func (*Gate) VerifyPassword ¶
type LocalSessionResult ¶
type LocalSessionResult struct {
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 RegisterChannelOptions struct {
Unlocked bool
}
type UnlockResult ¶
Click to show internal directories.
Click to hide internal directories.