authz

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package authz defines the trusted authorization boundary for native capability calls.

Index

Constants

This section is empty.

Variables

View Source
var ErrDenied = errors.New("authorization denied")

ErrDenied classifies a recognized authorization denial.

An authorizer may wrap ErrDenied with trusted diagnostic context. Callers must not expose the wrapped error text to untrusted clients.

Functions

func WithSubject

func WithSubject(ctx context.Context, subject Subject) context.Context

WithSubject returns a child context containing a trusted authenticated subject.

Hosts must derive subject from their authentication boundary before calling WithSubject. Tool arguments, program source, and MCP request metadata are not trusted identity sources.

Types

type AllowAllAuthorizer

type AllowAllAuthorizer struct{}

AllowAllAuthorizer explicitly permits every authorization input.

func AllowAll

func AllowAll() AllowAllAuthorizer

AllowAll returns an explicit authorizer that permits every invocation.

func (AllowAllAuthorizer) Authorize

Authorize permits the invocation without inspecting its input.

type AuthorizationInput

type AuthorizationInput struct {
	// Subject is the authenticated identity resolved from trusted host context.
	Subject Subject

	// CapabilityID is the capability's stable policy identity.
	CapabilityID string

	// CapabilityName is the model-facing dotted capability name.
	CapabilityName string

	// Arguments is a fresh canonical JSON-shaped projection of validated arguments.
	Arguments map[string]any
}

AuthorizationInput contains the complete trusted input for one authorization decision.

type Authorizer

type Authorizer interface {
	// Authorize returns nil to allow the invocation, an error wrapping ErrDenied for a recognized denial,
	// or another error when policy evaluation fails.
	Authorize(context.Context, AuthorizationInput) error
}

Authorizer decides whether a subject may perform one validated native invocation.

type Subject

type Subject struct {
	// ID is the caller's stable, non-secret identity.
	ID SubjectID
}

Subject identifies the authenticated caller used for authorization decisions.

func SubjectFromContext

func SubjectFromContext(ctx context.Context) (Subject, bool)

SubjectFromContext returns the trusted subject stored by WithSubject.

type SubjectID

type SubjectID string

SubjectID is a stable, non-secret authenticated identity.

Directories

Path Synopsis
Package mocks contains generated test doubles for authorization ports.
Package mocks contains generated test doubles for authorization ports.
Package rego implements authz.Authorizer with one prepared in-process Rego decision.
Package rego implements authz.Authorizer with one prepared in-process Rego decision.

Jump to

Keyboard shortcuts

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