Documentation
¶
Index ¶
- Constants
- func DefaultMaskFields() []string
- func HandleDefaultQueue(handler func(context.Context, Entry) error, options ...queue.JobOption)
- func HandleQueue(registry *queue.Registry, handler func(context.Context, Entry) error, ...)
- func Mask(input core.Map, fields []string, value string) core.Map
- func Provider(config Config) runaprovider.Provider
- func Record(ctx context.Context, writer Writer, entry Entry) error
- func Write(ctx context.Context, config Config, entry Entry) error
- type Config
- type Data
- type Entry
- type FuncWriter
- type Mode
- type Registry
- type Writer
- func DefaultLogWriter(channels ...string) Writer
- func DefaultQueueWriter(queueName string, options ...queue.PushOption) Writer
- func LogWriter(registry *runlog.Registry, channels ...string) Writer
- func MultiWriter(writers ...Writer) Writer
- func NoopWriter() Writer
- func QueueWriter(registry *queue.Registry, queueName string, options ...queue.PushOption) Writer
Constants ¶
const JobName = "runa.audit"
Variables ¶
This section is empty.
Functions ¶
func DefaultMaskFields ¶
func DefaultMaskFields() []string
DefaultMaskFields returns default sensitive field names.
func HandleDefaultQueue ¶
HandleDefaultQueue registers the audit queue handler on the default queue registry.
func HandleQueue ¶
func HandleQueue(registry *queue.Registry, handler func(context.Context, Entry) error, options ...queue.JobOption)
HandleQueue registers the audit queue handler.
func Provider ¶
func Provider(config Config) runaprovider.Provider
Provider registers audit config through Runa lifecycle.
Types ¶
type Config ¶
type Config struct {
Methods []string `toml:"methods"`
Mode Mode `toml:"mode"`
Strict bool `toml:"strict"`
Write func(ctx context.Context, entry Entry) error `toml:"-"`
Writer Writer `toml:"-"`
CaptureInput bool `toml:"capture_input"`
MaskFields []string `toml:"mask_fields"`
MaskValue string `toml:"mask_value"`
MaxInputSize int `toml:"max_input_size"`
Buffer int `toml:"buffer"`
WriteTimeout time.Duration `toml:"write_timeout"`
}
Config configures audit middleware.
type Entry ¶
type Entry struct {
ID string `json:"id,omitempty"`
Time time.Time `json:"time"`
Method string `json:"method"`
Path string `json:"path"`
Route string `json:"route,omitempty"`
Action string `json:"action,omitempty"`
Status int `json:"status"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Duration time.Duration `json:"duration"`
ActorID string `json:"actor_id,omitempty"`
ActorName string `json:"actor_name,omitempty"`
Guard string `json:"guard,omitempty"`
IP string `json:"ip,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
RequestID string `json:"request_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
Input core.Map `json:"input,omitempty"`
Meta core.Map `json:"meta,omitempty"`
}
Entry describes one business operation audit record.
type FuncWriter ¶
FuncWriter adapts a function to Writer.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores normalized audit configuration.
type Writer ¶
Writer writes audit entries.
func DefaultLogWriter ¶
DefaultLogWriter writes audit records to the default Runa logger registry.
func DefaultQueueWriter ¶
func DefaultQueueWriter(queueName string, options ...queue.PushOption) Writer
DefaultQueueWriter pushes audit entries into the default queue registry.
func MultiWriter ¶
MultiWriter combines multiple writers.
func QueueWriter ¶
QueueWriter pushes audit entries into a Runa queue registry.