sessionctx

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const OwnerScopeMigrationRequiredCode = "owner_scope_migration_required"

Variables

View Source
var ErrInvalidResourceScope = errors.New("resource owner scope is invalid")
View Source
var ErrInvalidSessionScope = errors.New("session scope is invalid")
View Source
var ErrOwnerScopeMigrationRequired = errors.New(OwnerScopeMigrationRequiredCode)

ErrOwnerScopeMigrationRequired rejects persisted resources whose owner scope cannot be reconstructed without guessing.

View Source
var ErrSessionRequired = errors.New("authenticated session is required")

Functions

func WithContext added in v0.5.0

func WithContext(ctx context.Context, session Context) context.Context

Types

type Context

type Context struct {
	OwnerSessionHash     string `json:"-"`
	OwnerUserHash        string `json:"-"`
	OwnerEnvHash         string `json:"-"`
	SessionChannelIDHash string `json:"-"`
}

func FromContext added in v0.5.0

func FromContext(ctx context.Context) (Context, bool)

func Require added in v0.5.0

func Require(ctx context.Context) (Context, error)

func (Context) ResourceScope added in v0.5.0

func (s Context) ResourceScope(kind ScopeKind) (ResourceScope, error)

func (Context) SessionScope added in v0.6.0

func (s Context) SessionScope() (SessionScope, error)

func (Context) Valid added in v0.5.0

func (s Context) Valid() bool

type ResourceScope added in v0.5.0

type ResourceScope struct {
	Kind          ScopeKind `json:"kind"`
	OwnerEnvHash  string    `json:"owner_env_hash"`
	OwnerUserHash string    `json:"owner_user_hash,omitempty"`
}

ResourceScope is the stable ownership boundary for persistent plugin data. Session and channel hashes are intentionally excluded: those values belong only to short-lived surfaces, operations, streams, and token audiences.

func (ResourceScope) Matches added in v0.5.0

func (s ResourceScope) Matches(other ResourceScope) bool

func (ResourceScope) Valid added in v0.5.0

func (s ResourceScope) Valid() bool

func (ResourceScope) Validate added in v0.5.0

func (s ResourceScope) Validate() error

type ScopeKind added in v0.5.0

type ScopeKind string
const (
	ScopeUser        ScopeKind = "user"
	ScopeEnvironment ScopeKind = "environment"
)

type SessionScope added in v0.6.0

type SessionScope struct {
	OwnerSessionHash     string `json:"-"`
	OwnerUserHash        string `json:"-"`
	OwnerEnvHash         string `json:"-"`
	SessionChannelIDHash string `json:"-"`
}

SessionScope is the exact ownership boundary for session capabilities. Its fields are deliberately excluded from JSON so authenticated owner identity cannot enter an HTTP or plugin-controlled payload by accident.

func (SessionScope) Matches added in v0.6.0

func (s SessionScope) Matches(other SessionScope) bool

func (SessionScope) Valid added in v0.6.0

func (s SessionScope) Valid() bool

func (SessionScope) Validate added in v0.6.0

func (s SessionScope) Validate() error

Jump to

Keyboard shortcuts

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