Documentation
¶
Overview ¶
Package auth defines stable, protocol-neutral authentication data shapes and event schemas for the plugin SDK. Core "ports" in internal/core/auth (Authenticator, RemoteDecider, EventSink) consume these DTOs; adapters map HTTP and configuration into InboundCallMeta and out of events.
Non-goals: this package does not implement policy, HTTP extraction, or remote clients. It does not use net/http, provider SDKs, enterprise transport, or canonical LLM event stream types.
Secret handling: InboundCallMeta may carry live bearer and session-hint material for policy evaluation on the request path; that data must not be copied into AuthDecisionEvent or SessionStartEvent, which are operator-visible audit views without raw tokens, API keys, SSO secrets, resume proofs, or personal OAuth access tokens.
Index ¶
- Constants
- func SanitizePublicChallengeSummary(summary, fallback string, maxRunes int) string
- type AccessMode
- type AuthDecisionEvent
- type Challenge
- type ChallengeKind
- type Decision
- type DecisionOutcome
- type DeviceIdentity
- type HandlerKind
- type InboundCallMeta
- type RequiredLevel
- type SessionCertainty
- type SessionStartEvent
Constants ¶
const ( HandlerLocalNoop HandlerKind = "local_noop" HandlerLocalAPIKey HandlerKind = "local_api_key" HandlerRemote HandlerKind = "remote" LevelNone RequiredLevel = "none" LevelAPIKey RequiredLevel = "api_key" LevelAPIKeySSO RequiredLevel = "api_key_sso" OutcomeAllow DecisionOutcome = "allow" OutcomeDeny DecisionOutcome = "deny" OutcomeChallenge DecisionOutcome = "challenge" // ChallengeSSORequired indicates a recognized app/device key but an unmet or missing SSO step. ChallengeSSORequired ChallengeKind = "sso_required" )
const DefaultChallengeSSOSummary = "Additional sign-in is required to use this key."
DefaultChallengeSSOSummary is the safe client-visible message when no custom summary is set.
const PublicChallengeSummaryMaxRunes = 256
PublicChallengeSummaryMaxRunes is the default and maximum safe length for SanitizePublicChallengeSummary when cap is non-positive. Keep call sites in sync (HTTP renderers, event dispatch, audit sinks).
Variables ¶
This section is empty.
Functions ¶
func SanitizePublicChallengeSummary ¶
SanitizePublicChallengeSummary bounds and filters challenge copy for HTTP responses and logs. Callers should treat Challenge.Summary as non-secret by contract; this applies defense in depth when a remote decider or policy bug places credential-like text in the summary.
Types ¶
type AccessMode ¶
type AccessMode string
AccessMode is deployment access posture at the time of an event (string for stable wire/logging).
const ( AccessSingleUser AccessMode = "single_user" AccessMultiUser AccessMode = "multi_user" )
type AuthDecisionEvent ¶
type AuthDecisionEvent struct {
Time time.Time
TraceID string
// Access and policy context (immutable snapshot at decision time)
AccessMode AccessMode
RequiredLevel RequiredLevel
HandlerKind HandlerKind
Frontend string
Outcome DecisionOutcome
ReasonCode string
// Principal is a safe snapshot: IDs and non-secret display metadata only.
PrincipalID string
PrincipalDisplayName string
PrincipalRoles []string
// PrincipalSafeClaims is keyed by non-empty trimmed claim names; values must remain empty
// on audit paths—do not place secret-bearing strings in map values.
PrincipalSafeClaims map[string]string
// Device is a non-secret snapshot: identifiers and redacted fingerprint only.
DeviceID string
DeviceKeyID string
DeviceFingerprint string
// Challenge, when applicable, is non-secret metadata.
ChallengeKind ChallengeKind
ChallengeSummary string
// Scope is an optional safe principal/scope snapshot from a trusted auth decision. It is
// nil when no scope was supplied. Raw secrets, transport headers, and resume authority
// must never be placed here (requirements 6.1, 2.6, 5.2).
Scope *scope.PrincipalScopeView
}
AuthDecisionEvent is a non-secret audit record for a single auth decision. It does not include raw bearer material, API keys, SSO or resume tokens, or personal OAuth access tokens.
PrincipalSafeClaims carries only claim key names (empty string values) when populated from stdhttp auth wiring; custom composition-root sinks must still avoid treating other event fields as proof that upstream state is free of secrets.
Any new exported field must be vetted as operator-safe and non-secret; custom sinks and log backends remain responsible for redaction policy beyond the core dispatcher's challenge-summary sanitization.
type Challenge ¶
type Challenge struct {
Kind ChallengeKind
ReasonCode string
// Summary is a short operator-safe, non-secret message (e.g. "SSO sign-in required").
Summary string
}
Challenge carries non-secret information about an auth challenge (e.g. SSO not satisfied even when a device or API key was recognized).
type ChallengeKind ¶
type ChallengeKind string
ChallengeKind categorizes a non-terminal auth challenge (no secret material).
type Decision ¶
type Decision struct {
Outcome DecisionOutcome
Principal execview.PrincipalView
Device DeviceIdentity
// SatisfiedLevel is the auth level the decision satisfied, if any, relative to policy.
SatisfiedLevel RequiredLevel
Challenge Challenge
// ReasonCode is a stable, machine-oriented reason (e.g. "invalid_api_key", "remote_denied").
ReasonCode string
// Scope carries an optional authoritative safe principal/scope snapshot supplied by
// trusted auth code. It is nil for legacy principal-only decisions. Raw bearer/API/OAuth/
// resume tokens and transport headers must never be placed here (requirements 2.1, 2.5, 2.6).
Scope *scope.PrincipalScopeView
// SubmissionAuthority carries optional trusted current-turn or continuation
// classification. Client payload metadata and headers are never promoted to
// this field; absence leaves prompt-priced submission charging unsupported.
SubmissionAuthority *submission.Authority
}
Decision is a single auth result for an inbound call.
type DecisionOutcome ¶
type DecisionOutcome string
DecisionOutcome is the result of an auth decision.
type DeviceIdentity ¶
DeviceIdentity distinguishes app, device, or key material from a human principal. Fingerprints and IDs must be non-secret (or redacted) when emitted to events.
type InboundCallMeta ¶
type InboundCallMeta struct {
TraceID string
Frontend string
Method string
Path string
// ClientAddr is a transport-level remote address (for example host:port). In some jurisdictions
// it may be treated as personal data; consider redaction and retention policies in logs and audits.
ClientAddr string
// AuthorizationBearer is the raw token from an HTTP Authorization header only when the scheme
// is Bearer; otherwise empty. Treat as secret at rest and in logs.
AuthorizationBearer string
// SessionHint is a client-supplied resume or session handle; may be secret if it authorizes.
SessionHint string
}
InboundCallMeta is protocol-neutral request metadata for authentication. Driving adapters (e.g. stdhttp) populate it. Secret-adjacent fields exist only here for policy evaluation; they are not part of public audit or session events.
func (InboundCallMeta) GoString ¶
func (m InboundCallMeta) GoString() string
GoString is an alias of InboundCallMeta.String so fmt %#v and representation helpers stay safe.
func (InboundCallMeta) String ¶
func (m InboundCallMeta) String() string
String returns a log-safe single-line description; bearer and session hints are redacted.
type RequiredLevel ¶
type RequiredLevel string
RequiredLevel is the policy-required authentication level for a route or deployment.
type SessionCertainty ¶
type SessionCertainty string
SessionCertainty describes how confidently the runtime associated this session with prior state.
const ( SessionCertaintyKnown SessionCertainty = "known" SessionCertaintyUnknown SessionCertainty = "unknown" SessionCertaintyPartial SessionCertainty = "partial" )
type SessionStartEvent ¶
type SessionStartEvent struct {
Time time.Time
TraceID string
AccessMode AccessMode
RequiredLevel RequiredLevel
HandlerKind HandlerKind
Frontend string
SessionID string
ClientSessionRef string
ALegID string
Certainty SessionCertainty
IsNew bool
PrincipalID string
PrincipalDisplayName string
}
SessionStartEvent is a non-secret record of a new or uncertain proxy-recognized session. ClientSessionRef is an opaque, non-secret client correlation id (not a resume proof or token). ALegID is a correlation id when present.
Any new exported field must be vetted as operator-safe and non-secret for logging and custom sinks.