audit

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package audit records the append-only admin/security audit log. It wraps store.AuditStore with fire-and-forget semantics: a write failure is logged but never propagated, so auditing can never fail the request it describes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoarseIP

func CoarseIP(addr string) string

CoarseIP reduces a "host:port" or bare-host address to a coarse network prefix so the audit log locates an action without storing a precise client address: IPv4 is masked to /24, IPv6 to /48. Unparseable input is returned as-is (already coarse or empty).

Types

type Sink

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

Sink appends audit records. Construct one per instance and share it across the handlers and the security-event emitters.

func New

func New(st store.AuditStore, log *slog.Logger, now func() time.Time) *Sink

New builds a Sink. now defaults to time.Now.

func (*Sink) Append

func (s *Sink) Append(ctx context.Context, e store.AuditEntry)

Append writes one audit entry, filling in its id and timestamp when the caller left them zero. It never blocks the caller on failure: a store error is logged and swallowed, because losing an audit line must not fail (or roll back) the action it records.

Jump to

Keyboard shortcuts

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