access

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package access carries admission policy without depending on a broker or UI.

Index

Constants

View Source
const (
	SessionRead         = "session:read"
	SessionRegister     = "session:register"
	SessionRename       = "session:rename"
	SessionManage       = "session:manage"
	SessionSpawn        = "session:spawn"
	MessageSend         = "message:send"
	MessageReceive      = "message:receive"
	MemoryRead          = "memory:read"
	MemoryWrite         = "memory:write"
	SessionRegisterAuto = "session:register:auto"
)
View Source
const ScopeVersion = 1
View Source
const TokenInfoTool = "session_token_info"

TokenInfoTool is callable for diagnostics but never advertised to a host.

Variables

View Source
var ErrInsufficientScope = errors.New("insufficient_scope")

ErrInsufficientScope is intentionally fixed: it reveals no token or scope list. It is a tool authorization failure, never an invalid-credential signal.

Functions

func DelegatedScopes

func DelegatedScopes(parent []string) []string

DelegatedScopes removes admission-only and retired permissions from a child snapshot.

func HasScope

func HasScope(scopes []string, scope string) bool

func IssuableScopes

func IssuableScopes(scopes []string) bool

IssuableScopes rejects retired permissions on new issuance and edits.

func LegacyV1Scopes

func LegacyV1Scopes() []string

LegacyV1Scopes is fixed to features available before scoped tokens. It is never a wildcard, never includes auto admission, and returns a private copy.

func RequireScope

func RequireScope(ctx context.Context, scope string) error

RequireScope narrows authenticated requests only. Local/internal callers without a grant keep their existing policy; a grant with missing scopes does not acquire legacy defaults. Authentication and object checks remain separate.

func RestrictedScopes

func RestrictedScopes(scopes []string) bool

RestrictedScopes reports a snapshot lacking any current full permission. Historical session:spawn does not count, so 8- and 9-scope full grants match.

func ScopesSubset

func ScopesSubset(child, parent []string) bool

func ValidScopes

func ValidScopes(scopes []string) bool

ValidScopes accepts only the canonical, nonempty stored representation. Historical session:spawn remains readable in old data and server responses. Missing, duplicate, unknown or reordered fields must not become full access.

func WireScopes

func WireScopes(scopes []string) []string

WireScopes re-adds retired session:spawn to a full snapshot sent to clients. shortcut: 0.15–0.19 clients treat fewer than nine scopes as restricted; remove at 2.0 when the minimum client checks RestrictedScopes.

func WithGrant

func WithGrant(ctx context.Context, grant Grant) context.Context

Types

type DetachedRemovalProof

type DetachedRemovalProof struct {
	RegistrationID, Identity, OwnerID, Name string
	AdmissionMode, GrantID, ParentID        string
	Revision                                uint64
	Detached, ReattachAfterCleanup          bool
}

DetachedRemovalProof is server-owned evidence captured under the broker lock. It is never transported to a client or logged as a raw binding identity.

type Grant

type Grant struct {
	Retire func(RetirementTarget, func() error) ([]protocol.RevokedCredential, error)

	ProjectGenerationID string // Authenticated server-owned project lifetime.
	// Rebind coordinates a durable manual-handover journal with policy. Server only.
	Rebind func(phase string, journal protocol.RebindJournal, result protocol.RebindResult) error

	// Manage rechecks live token and web management policy for another registration.
	// Called under the broker mutation lock; arguments are server-owned.
	Manage                  func(identity, recordedOwner string) error
	ManagementAudit         func(protocol.ManagementEvent) error
	CancelSuspendedRequests func(nickname string)

	// Registration is server-only admission/confirmation for direct grants.
	// The false phase runs under the broker mutation lock before its commit.
	Registration            func(identity, id, owner, name string, revision uint64, confirmed bool) error
	ParentID, AdmissionMode string
	// Scopes is a server-owned copy of the persisted child permission snapshot.
	Scopes                     []string
	ExpiresAt                  time.Time
	Revoked                    <-chan struct{}
	Project, TokenID, Nickname string
	// OwnerID is assigned by the server policy store, never decoded from a client.
	OwnerID string
	// Claim binds this token to the canonical client+harness+session identity.
	// Use only for admission after validating ownership of any existing record.
	// It rechecks live policy each time.
	Claim func(identity string) error
	// Connected confirms the first successful durable registration. Admission
	// alone must not prevent an unused token from expiring.
	Connected func(identity string) error
	// Check requires an existing matching binding and never binds an identity.
	// Use before operations on an already registered session.
	Check func(identity string) error
	// CheckName revalidates the current durable name, including recovery of an
	// interrupted rename. It is called under the broker's registration lock.
	CheckName func(identity, name string) error
	// Rename reserves the new name durably, applies the registration write,
	// then finalizes policy. apply must not call back into this policy store.
	Rename func(identity, oldName, newName string, apply func() error) error
}

func FromContext

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

type RetirementTarget

type RetirementTarget struct {
	Identity, Name, RecordedOwner, RegistrationID string
	Event                                         protocol.ManagementEvent
}

RetirementTarget is server-owned and used only under the broker mutation lock.

type ScopeDetail

type ScopeDetail struct {
	Scope       string `json:"scope"`
	Label       string `json:"label"`
	Description string `json:"description"`
}

ScopeDetail is shared by token issuance and credential diagnostics.

func ScopeCatalog

func ScopeCatalog() []ScopeDetail

ScopeCatalog returns a copy in canonical scope order. Descriptions describe permission checks; identity/ownership checks still apply independently.

func ScopeDetails

func ScopeDetails(scopes []string) []ScopeDetail

type TokenInfo

type TokenInfo struct {
	ProjectGenerationID string    `json:"projectGenerationId,omitempty"`
	ProjectRefusals     bool      `json:"projectRefusals,omitempty"`
	Scopes              []string  `json:"scopes"`
	AdmissionMode       string    `json:"admissionMode"`
	ExpiresAt           time.Time `json:"expiresAt,omitzero"`
}

Jump to

Keyboard shortcuts

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