Documentation
¶
Overview ¶
Package audit defines the security events IAM emits (logins, logouts, refreshes, refresh-token reuse, revocations, policy denials, sign-ups, invites, throttling, password resets, email verification, MFA) and the Logger interface that receives them.
IAM decides what happened; the Logger decides where it goes. SlogLogger writes to log/slog; Multi and Func compose custom sinks. Events never contain passwords, tokens or session secrets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Time time.Time
Type EventType
SubjectID string // canonical subject ID (if known)
SessionID string // public session ID (if known)
Provider string // auth provider involved (if applicable)
ClientIP string // client address as seen by the application
Message string // human-readable description
Attrs map[string]string // extensible metadata (reason, count, ...)
}
Event represents a single audit log entry.
Audit events are intentionally generic so they can be:
- written to logs
- pushed to SIEM systems
- stored in databases
- streamed to Kafka
Events never contain secrets: no passwords, tokens or session secrets. SessionID is the public session identifier.
type EventType ¶
type EventType string
EventType represents the category of an audit event.
These events are security-relevant and should be treated as immutable.
const ( EventLoginSuccess EventType = "login_success" EventLoginFailure EventType = "login_failure" EventLogout EventType = "logout" EventRefreshSuccess EventType = "refresh_success" EventRefreshFailure EventType = "refresh_failure" EventRefreshReuse EventType = "refresh_reuse_detected" EventSessionRotated EventType = "session_rotated" EventSessionRevoked EventType = "session_revoked" EventSessionsRevokedAll EventType = "sessions_revoked_all" EventTokenVerifyFailure EventType = "token_verify_failure" EventPolicyDenied EventType = "policy_denied" EventIdentityLinked EventType = "identity_linked" EventSignup EventType = "signup" EventInviteCreated EventType = "invite_created" EventInviteConsumed EventType = "invite_consumed" EventInviteRevoked EventType = "invite_revoked" EventRateLimited EventType = "rate_limited" EventLockout EventType = "lockout" EventPasswordResetRequested EventType = "password_reset_requested" EventPasswordReset EventType = "password_reset" EventPasswordChanged EventType = "password_changed" EventEmailVerificationRequested EventType = "email_verification_requested" EventEmailVerified EventType = "email_verified" EventMFAChallenge EventType = "mfa_challenge" EventMFASuccess EventType = "mfa_success" EventMFAFailure EventType = "mfa_failure" EventMFAEnrolled EventType = "mfa_enrolled" EventMFADisabled EventType = "mfa_disabled" EventRecoveryCodeUsed EventType = "mfa_recovery_code_used" EventRecoveryCodesIssued EventType = "mfa_recovery_codes_issued" )
type Logger ¶
Logger defines the contract for recording audit events.
IAM emits audit events but does NOT decide where they go. Log is called synchronously on the request path; slow sinks should buffer internally. Errors are reported to the caller but never fail the operation.
type SlogLogger ¶
type SlogLogger struct {
// Logger receives the events. Nil means slog.Default().
Logger *slog.Logger
}
SlogLogger writes audit events to a log/slog logger.
Event attributes are written as a group. Callers must never put secrets (tokens, passwords, session secrets) into an Event.
func NewSlogLogger ¶
func NewSlogLogger(l *slog.Logger) *SlogLogger
NewSlogLogger returns an audit logger that writes to l (nil means slog.Default()).