Documentation
¶
Overview ¶
Package actor carries the identity of the caller making a request.
An Actor is relay's view of the auth module's principal: the control-plane middleware converts the principal its authenticator chain produced (FromPrincipal) and handlers read it via From(ctx).
Handlers should never read cookies or tokens directly — they go through the Actor in context. This keeps call sites stable across changes to the identity backend (YAML today, Postgres/Kratos/SuperTokens later).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Actor ¶
type Actor struct {
// UserID is the durable reference (UUIDv7). Empty means "no user" —
// usually the admin-token bypass path or anonymous inference traffic.
UserID string
// Username is the display name. Subject to change; never use it as
// a join key.
Username string
// SessionID identifies the session this actor came from, for audit
// correlation. It is derived from, never equal to, the session token: it
// is stored and shown to audit readers. Empty for the admin-token bypass.
SessionID string
// AdminToken is true when this actor came from the RELAY_ADMIN_TOKEN
// bypass instead of a user session. Authz can grant blanket
// permissions to break-glass callers.
AdminToken bool
// Roles are carried verbatim from the user record at session build;
// app/authz interprets them. Empty for the admin-token bypass (which
// AdminToken already marks as all-powerful).
Roles []string
// Subjects are the RBAC subject strings this caller acts under
// ("user:<id>", "group:<name>", …). Built once per request by the
// session middleware; handlers never assemble them. Empty for the
// admin-token bypass, which authz short-circuits.
Subjects []string
// IdPGroups are the group names an identity provider asserted at login,
// carried verbatim from the session. Empty for password logins and the
// admin-token bypass.
IdPGroups []string
}
Actor is the authenticated caller for the current request.
func FromPrincipal ¶ added in v0.10.8
FromPrincipal converts an authenticated principal to an Actor. The admin-kind principal is the admin-token bypass.
func (*Actor) IsAuthenticated ¶
IsAuthenticated reports whether the actor represents any kind of valid caller (real user session or admin-token bypass).