Documentation
¶
Overview ¶
Package access carries admission policy without depending on a broker or UI.
Index ¶
- Constants
- Variables
- func DelegatedScopes(parent []string) []string
- func HasScope(scopes []string, scope string) bool
- func IssuableScopes(scopes []string) bool
- func LegacyV1Scopes() []string
- func RequireScope(ctx context.Context, scope string) error
- func RestrictedScopes(scopes []string) bool
- func ScopesSubset(child, parent []string) bool
- func ValidScopes(scopes []string) bool
- func WireScopes(scopes []string) []string
- func WithGrant(ctx context.Context, grant Grant) context.Context
- type DetachedRemovalProof
- type Grant
- type RetirementTarget
- type ScopeDetail
- type TokenInfo
Constants ¶
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" )
const ScopeVersion = 1
const TokenInfoTool = "session_token_info"
TokenInfoTool is callable for diagnostics but never advertised to a host.
Variables ¶
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 ¶
DelegatedScopes removes admission-only and retired permissions from a child snapshot.
func IssuableScopes ¶
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 ¶
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 ¶
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 ValidScopes ¶
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 ¶
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.
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
}
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