Documentation
¶
Overview ¶
Package audit writes who changed what into an app's audit_events table (schema.sql), in the transaction of the change, and pages through it for a back office.
The account actions of package backoffice are listed here; an app adds the codes of its own domain.
Index ¶
Constants ¶
const ( SignedIn = "signed_in" SignedUp = "signed_up" SignedOut = "signed_out" RoleChanged = "role_changed" UserRestrained = "user_restrained" UserRestored = "user_restored" UserApproved = "user_approved" ImpersonationStarted = "impersonation_started" ImpersonationStopped = "impersonation_stopped" AnnouncementSet = "announcement_set" AnnouncementCleared = "announcement_cleared" )
Codes of the account actions. Rows keep them: never rename one, add a new code.
const Layout = "2006-01-02T15:04:05.000Z"
Layout is the fixed-width UTC layout of audit_events.at.
Variables ¶
var AccountActions = []string{ SignedIn, SignedUp, SignedOut, RoleChanged, UserRestrained, UserRestored, UserApproved, ImpersonationStarted, ImpersonationStopped, AnnouncementSet, AnnouncementCleared, }
AccountActions lists the account codes in the order a back office filter shows them.
Functions ¶
func After ¶
After writes the audit row of a committed change and logs a failure. Never inside a transaction: on a database with a single pooled connection, the write would wait for the transaction forever.
Types ¶
type Event ¶
type Event struct {
ID int64 `json:"id"`
At string `json:"at"`
ActorID string `json:"actor_id"`
Action string `json:"action"`
Target string `json:"target"`
Details json.RawMessage `json:"details"`
}
Event is one audit row.
type Execer ¶
type Execer interface {
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
Execer is a *sql.DB or a *sql.Tx.