Documentation
¶
Overview ¶
Package audit provides HTTP middleware for audit logging and query handler for audit log access.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware creates middleware that logs audit entries after handler completes. This is a convenience function that creates a logger and returns its middleware.
Types ¶
type Auth ¶
type Auth interface {
GetRequestActor(r *http.Request) (actorType, actorName string)
IsRequestAdmin(r *http.Request) bool
}
Auth defines the interface for auth operations needed by audit.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles audit query requests.
func NewHandler ¶
NewHandler creates a new audit handler.
func (*Handler) HandleQuery ¶
func (h *Handler) HandleQuery(w http.ResponseWriter, r *http.Request)
HandleQuery handles POST /audit/query requests. Requires admin privileges via session cookie or API token with admin flag.
type QueryRequest ¶
type QueryRequest struct {
Key string `json:"key,omitempty"` // prefix match with * suffix
Actor string `json:"actor,omitempty"` // exact match
ActorType string `json:"actor_type,omitempty"` // user, token, public
Action string `json:"action,omitempty"` // read, create, update, delete
Result string `json:"result,omitempty"` // success, denied, not_found
From string `json:"from,omitempty"` // RFC3339 timestamp
To string `json:"to,omitempty"` // RFC3339 timestamp
Limit int `json:"limit,omitempty"` // max entries to return
}
QueryRequest represents the JSON request for audit query.
type QueryResponse ¶
type QueryResponse struct {
Entries []store.AuditEntry `json:"entries"`
Total int `json:"total"`
Limit int `json:"limit"`
}
QueryResponse represents the JSON response for audit query.
type Store ¶
type Store interface {
LogAudit(ctx context.Context, entry store.AuditEntry) error
QueryAudit(ctx context.Context, q store.AuditQuery) ([]store.AuditEntry, int, error)
}
Store defines the interface for audit log storage.