authidentity

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package authidentity carries who authenticated a gateway request, and how, on the request context. The proxy's credential validator records it; the analytics writers, the post-auth hook and the plugins read it. It is a leaf package so analytics can read it without importing the proxy.

Index

Constants

View Source
const (
	MethodAppKey = "app_key" // an app secret, as a bearer token or an API key
	MethodOAuth  = "oauth"   // a Studio OAuth access token (MCP)
	MethodPlugin = "plugin"  // an auth plugin
)

Authentication methods (Identity.Method).

View Source
const ClaimActor = "auth_actor"

ClaimActor is the claim an auth plugin sets to the agent acting for the subject (a delegated token's act or azp). It is recorded with the request as the acting agent.

Variables

This section is empty.

Functions

func With

func With(ctx context.Context, id *Identity) context.Context

With returns ctx carrying id.

Types

type Identity

type Identity struct {
	AppID  uint
	Method string // Method*
	// The plugin that authenticated the request (MethodPlugin).
	PluginID   uint
	PluginName string
	// Subject is who the call is for, when an auth plugin says (its user
	// id). It is recorded for audit and never used for authorisation.
	Subject string
	Claims  map[string]string
	// OAuthUserID is the Studio user an OAuth access token was issued to.
	OAuthUserID uint
}

Identity is who authenticated a request and how.

func From

func From(ctx context.Context) *Identity

From returns the identity recorded on ctx, or nil.

func (*Identity) ActingAgent

func (id *Identity) ActingAgent() string

ActingAgent is the agent acting for the subject, as recorded in analytics; empty unless an auth plugin named one (ClaimActor).

func (*Identity) OnBehalfOf

func (id *Identity) OnBehalfOf() string

OnBehalfOf is the subject the request was made for, as recorded in analytics; empty unless an auth plugin named one.

Jump to

Keyboard shortcuts

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