identity

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package identity carries the authenticated caller identity on the request context. It lives outside package server so the provider layer can read it without an import cycle — per-principal key routing resolves from exactly this, never from anything client-supplied. The fields are GENERIC: who the caller is, which vendors they hold keys for, and whether serving is limited to those keyed vendors. What POPULATES them (a local token, or a hosted verification service) is the composition's business — this package encodes no commercial concepts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func With(ctx context.Context, info Info) context.Context

With stamps the identity on the context.

Types

type Info

type Info struct {
	// OrgID / UserID scope the principal (a tenant + a user within it; both
	// "selfhost" in the default composition). They are the key-lookup scope
	// and the rate-limit / usage dimension.
	OrgID  string
	UserID string

	// KeyedVendors are the vendors this principal holds serving keys for via
	// the composition's KeySource. The presence gate: keys are resolved only
	// for vendors listed here.
	KeyedVendors []string

	// LimitToKeyed means serving must use a keyed vendor — a non-keyed lane
	// refuses rather than serving on the gateway's own keys. Always false in
	// the default (self-host) composition; a hosted composition sets it (e.g.
	// a hosted composition's usage limit). The refusal is the wire's insufficient_credits code.
	LimitToKeyed bool
}

Info is the verified identity of one request, stamped by the auth middleware from the composition's Authenticator + Authorizer.

func From

func From(ctx context.Context) Info

From reads the identity stamped by the auth middleware. The zero Info means "not authenticated" — callers on authed paths can rely on OrgID being set.

func (Info) HasKey added in v0.9.0

func (i Info) HasKey(vendor string) bool

HasKey reports whether the principal has a serving key for the vendor.

Jump to

Keyboard shortcuts

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