middleware

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package middleware holds HTTP middleware specific to the RA.

Ownership enforcement lives here because it's a cross-cutting concern every agent-scoped route needs — putting it in the handlers would force every handler to duplicate the store lookup + owner check.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentFromContext

func AgentFromContext(ctx context.Context) (*domain.AgentRegistration, bool)

AgentFromContext returns the ownership-verified agent attached by Ownership middleware. Handlers call this instead of re-querying the store, ensuring they never operate on an agent they didn't prove ownership of.

func ReadOwnership

func ReadOwnership(store port.AgentStore) func(http.Handler) http.Handler

ReadOwnership returns middleware appropriate for GET handlers. A missing-or-not-owned agent produces 404 — the V2 spec deliberately collapses "doesn't exist" and "not yours" to hide existence from unauthorized callers.

func WriteOwnership

func WriteOwnership(store port.AgentStore) func(http.Handler) http.Handler

WriteOwnership returns middleware appropriate for write (POST/DELETE) handlers. Missing agent → 404; present but not owned → 403. Writes use the explicit split because a 404-for-not-owned would hide a real authorization failure from operators investigating permissions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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