sessionctx

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 4 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

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:"-"`
	// CanRead and CanWrite are Host-authenticated filesystem ceilings. They are
	// deliberately excluded from durable ownership scopes and serialized APIs.
	CanRead  bool `json:"-"`
	CanWrite bool `json:"-"`
}

func FromContext

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

func Require

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

func (Context) ResourceScope

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

func (Context) SessionScope

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

func (Context) Valid

func (s Context) Valid() bool

type ResourceScope

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

func (s ResourceScope) Matches(other ResourceScope) bool

func (ResourceScope) Valid

func (s ResourceScope) Valid() bool

func (ResourceScope) Validate

func (s ResourceScope) Validate() error

type ScopeKind

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

type SessionScope

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

func (s SessionScope) Matches(other SessionScope) bool

func (SessionScope) Valid

func (s SessionScope) Valid() bool

func (SessionScope) Validate

func (s SessionScope) Validate() error

Jump to

Keyboard shortcuts

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