audit

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package audit defines the append-only audit contract. The Postgres store is the system of record; sinks fan events out (OTLP, syslog, SIEM). Audit is free forever — never gate it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelegationFrom added in v0.8.0

func DelegationFrom(ctx context.Context) (types.DelegationVia, bool)

DelegationFrom reports the portal and delegated token ctx's request came through, when it did.

func LogWriteFailure added in v0.3.1

func LogWriteFailure(ctx context.Context, ev types.AuditEvent, err error)

LogWriteFailure reports a dropped audit write at ERROR level so an operator can alert on it; it must never block the caller.

ev.Data is deliberately NOT logged: it can carry sensitive per-action payloads (grant scopes, jti, approval ids). Callers must not add it here.

func StampDelegation added in v0.8.0

func StampDelegation(ctx context.Context, data json.RawMessage) json.RawMessage

StampDelegation returns data with the portal added under "via" when ctx is a delegated request, and data unchanged otherwise. Data that is not a JSON object is kept whole under "data", so no delegated row can lack the stamp.

func WithDelegation added in v0.8.0

func WithDelegation(ctx context.Context, via types.DelegationVia) context.Context

WithDelegation marks ctx as a request made through via.

Types

type DelegationRecorder added in v0.8.0

type DelegationRecorder struct{ Inner Recorder }

DelegationRecorder stamps data.via on every event recorded under a delegated context, whoever wrote it. cmd/wardynd puts it at the head of the shared chain.

func (DelegationRecorder) Record added in v0.8.0

Record stamps ev when ctx is delegated and hands it on.

type Recorder

type Recorder interface {
	Record(ctx context.Context, ev types.AuditEvent) error
}

Recorder persists events to the system of record (append-only).

type Sink

type Sink interface {
	Name() string // "otlp" | "syslog" | ...
	Emit(ctx context.Context, ev types.AuditEvent) error
}

Sink streams recorded events to an external destination. Sinks must not block recording; failures are logged and retried, never silently dropped.

Directories

Path Synopsis
Package sinks provides production audit.Sink implementations (syslog, webhook, file) plus a Fanout multiplexer and config wiring.
Package sinks provides production audit.Sink implementations (syslog, webhook, file) plus a Fanout multiplexer and config wiring.

Jump to

Keyboard shortcuts

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