audit

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Overview

Package audit appends to the append-only events table (plan §5.8). It never records secret values — callers pass already-redacted detail strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Actor   string
	IP      string
	Action  string
	Target  string
	Outcome Outcome
	Level   Level
	Detail  string
}

Event is one audit record.

type Level

type Level string

Level distinguishes routine actions from security-relevant ones.

const (
	Info     Level = "info"
	Security Level = "security"
)

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger writes audit events.

func New

func New(db *store.DB, log *slog.Logger) *Logger

New returns a Logger backed by db. log (may be nil) receives a line whenever an audit write FAILS, so a dropped security event is never invisible (review #12).

func (*Logger) Log

func (l *Logger) Log(ctx context.Context, e Event) error

Log appends an event. A DB failure is returned AND logged (if a logger is set): it is non-fatal to the request path (the request still fails closed on its own merits), but the dropped event must not vanish silently.

type Outcome

type Outcome string

Outcome of an audited action.

const (
	OK    Outcome = "ok"
	Deny  Outcome = "deny"
	Error Outcome = "error"
)

Jump to

Keyboard shortcuts

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