Documentation
¶
Overview ¶
Package audit appends rows to the audit_log table. Write runs inside the transaction of the change it records, so a change and its audit trail commit or roll back together.
Index ¶
Constants ¶
const ( KindUser = "user" KindConsole = "console" KindSystem = "system" KindApp = "app" )
Actor kinds.
const ( ActionSetup = "setup.complete" ActionLoginSuccess = "auth.login" ActionLoginFailure = "auth.login_failed" ActionLogout = "auth.logout" ActionPasswordChange = "auth.password_change" ActionPasswordReset = "auth.password_reset" ActionResetCreate = "auth.reset_create" ActionInviteCreate = "invite.create" ActionInviteAccept = "invite.accept" ActionInviteRevoke = "invite.revoke" ActionRegister = "user.register" ActionSessionRevoke = "session.revoke" ActionDeviceLogin = "device.login" ActionDeviceRevoke = "device.revoke" ActionHandoff = "auth.handoff" ActionSettingsUpdated = "settings.update" )
Actions recorded by the auth and settings code. Detail never carries passwords, tokens, invite or reset codes.
const ( ActionUserUpdate = "user.update" ActionTLSReissue = "tls.reissue" ActionChannelAdmin = "channel.admin_update" )
Further actions recorded by the admin endpoints.
const ( DefaultListLimit = 50 MaxListLimit = 200 )
List limits.
Variables ¶
var Console = Actor{Kind: KindConsole}
Console is the actor of the admin CLI (console access is the root of trust).
var ErrBadCursor = errors.New("audit: invalid cursor")
ErrBadCursor means a list cursor was not produced by List.
var System = Actor{Kind: KindSystem}
System is the actor of background work.
Functions ¶
func HasRemoteActor ¶
HasRemoteActor reports whether any row of the given actions was performed from an address other than loopback (the client-isolation hint of the admin overview).
Types ¶
type Actor ¶
type Actor struct {
// ID is the user id; empty for the console and the system.
ID string
// Kind is one of the Kind* constants.
Kind string
// IP is the client address; empty when there is none.
IP string
}
Actor identifies who performs an action.
type Entry ¶
type Entry struct {
ActorID string
ActorKind string
ActorIP string
Action string
TargetType string
TargetID string
// Detail is marshaled to JSON; nil stores {}.
Detail any
}
Entry is one audit_log row.
type ListParams ¶
type ListParams struct {
// Cursor is the NextCursor of the previous page; empty starts at the newest row.
Cursor string
// Action keeps only rows with exactly this action.
Action string
// Limit is the page size; 0 means DefaultListLimit.
Limit int
}
ListParams selects a page of the log, newest first.