security

package
v0.70.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 9 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 the session-hijack-prevention decorator for vMCP sessions. It binds a session to the identity that created it: issuer and subject, plus route, client_id and actor for delegated identities. It validates that every subsequent request comes from the same identity.

Session bindings are stored as plaintext at rest in the session metadata (see pkg/vmcp/session/binding for the format and trust-boundary statement). The binding is NOT a credential; it identifies but does not authenticate. Callers must validate the request's token independently before passing the resulting *auth.Identity to validateCaller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindSession added in v0.29.0

func BindSession(
	session sessiontypes.MultiSession,
	bindingID string,
) (sessiontypes.MultiSession, error)

BindSession wraps a session with identity-binding validation. It writes bindingID, as returned by ResolveBinding, into session metadata under MetadataKeyIdentityBinding and returns a decorator that validates the caller on every operation.

Returns an error BEFORE writing anything to the session metadata if session is nil or bindingID is neither the unauthenticated sentinel nor a valid binding — preserving the invariant that a session always has a valid MetadataKeyIdentityBinding value once written.

func ResolveBinding added in v0.70.0

func ResolveBinding(identity *auth.Identity) (string, error)

ResolveBinding determines the metadata binding for a new session. It returns binding.UnauthenticatedSentinel for anonymous identities, so a result equal to the sentinel means the session is anonymous, and an error if a required binding cannot be derived. Call it once per session and pass the result to BindSession.

func RestoreSessionBinding added in v0.29.0

func RestoreSessionBinding(
	session sessiontypes.MultiSession,
	storedBinding string,
) (sessiontypes.MultiSession, error)

RestoreSessionBinding recreates the session-binding decorator from a persisted binding string read out of session metadata. Use this when reconstructing a MultiSession after a pod restart or cross-pod failover.

This function is the symmetric counterpart of BindSession for the restore path. It is invoked by the session factory after RestoreSession deserializes the binding from session metadata. Unlike BindSession, it does NOT write metadata — the factory has already restored the metadata layer separately.

storedBinding must be either:

  • binding.UnauthenticatedSentinel (the session was anonymous), or
  • a valid bound binding (binding.Parse returns ok), including the delegated forms.

Anything else (empty string, malformed value) is rejected as corrupted metadata.

func ValidateCaller added in v0.30.0

func ValidateCaller(storedBinding string, caller *auth.Identity) error

ValidateCaller checks caller against a stored identity-binding string (the value persisted under MetadataKeyIdentityBinding). It reproduces the decorator's per-request check for call paths that do not go through the [sessionBindingDecorator] — notably the Serve transport path, where the advertised set and call routing are owned by the core but identity binding must still be enforced by the session layer.

allowAnonymous is derived from storedBinding: an anonymous session stores the UnauthenticatedSentinel, so IsUnauthenticated(storedBinding) is exactly the allowAnonymous flag BindSession recorded (ResolveBinding decides whether the session is anonymous, and BindSession writes the value it resolved).

Types

This section is empty.

Jump to

Keyboard shortcuts

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