security

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 15 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 security provides authenticated subject isolation helpers.

Index

Constants

View Source
const LocalSubject = "local-stdio"

LocalSubject is the shared subject for unauthenticated local transports.

Variables

This section is empty.

Functions

func RequireSubject

func RequireSubject(ctx context.Context, owner string) error

RequireSubject verifies ownership without revealing cross-subject objects.

func SubjectFromContext

func SubjectFromContext(ctx context.Context) string

SubjectFromContext returns the authenticated subject or the local transport subject.

Types

type OwnedRecord

type OwnedRecord[T any] struct {
	ID        string
	Owner     string
	CreatedAt time.Time
	Value     T
}

OwnedRecord is a value associated with the subject that created it.

type RequestStateClaims added in v0.14.0

type RequestStateClaims struct {
	Version     int            `json:"version"`
	Subject     string         `json:"subject"`
	Operation   string         `json:"operation"`
	InputDigest string         `json:"inputDigest"`
	PlanDigest  string         `json:"planDigest"`
	ExpiresAt   int64          `json:"expiresAt"`
	Data        jsontext.Value `json:"data,omitzero"`
}

RequestStateClaims binds an MCP multi-round-trip retry to the operation that requested input.

type RequestStateSigner added in v0.14.0

type RequestStateSigner struct {
	// contains filtered or unexported fields
}

RequestStateSigner signs and verifies opaque MCP multi-round-trip request state.

func NewRandomRequestStateSigner added in v0.14.0

func NewRandomRequestStateSigner() (*RequestStateSigner, error)

NewRandomRequestStateSigner constructs a signer with a process-local random key.

func NewRequestStateSigner added in v0.14.0

func NewRequestStateSigner(key []byte) (*RequestStateSigner, error)

NewRequestStateSigner constructs a signer from key. The key must contain at least 32 bytes.

func (*RequestStateSigner) Sign added in v0.14.0

Sign returns integrity-protected opaque request state.

func (*RequestStateSigner) Verify added in v0.14.0

func (s *RequestStateSigner) Verify(token string) (RequestStateClaims, error)

Verify authenticates and decodes opaque request state.

type Store

type Store[T any] struct {
	// contains filtered or unexported fields
}

Store is an in-memory subject-isolated record store.

func (*Store[T]) Get

func (s *Store[T]) Get(ctx context.Context, id string) (T, bool, error)

Get returns a value only when it belongs to the current subject.

func (*Store[T]) Put

func (s *Store[T]) Put(ctx context.Context, id string, value T)

Put stores value under id for the current subject.

Jump to

Keyboard shortcuts

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