Back to godoc.org

Package auditlog

v0.0.0-...-4d7de85
Latest Go to latest

The latest major version is .

Published: Oct 15, 2020 | License: Apache-2.0 | Module: github.com/banzaicloud/pipeline

Index

func Middleware

func Middleware(driver Driver, opts ...Option) gin.HandlerFunc

Middleware returns a new HTTP middleware that records audit log entries.

type Clock

type Clock interface {
	Now() time.Time
	Since(time.Time) time.Duration
}

Clock provides time.

type Driver

type Driver interface {
	// Store saves an audit log entry.
	Store(entry Entry) error
}

Driver saves audit log entries.

type Drivers

type Drivers []Driver

Drivers combine multiple drivers into a single instance.

func (Drivers) Store

func (d Drivers) Store(entry Entry) error

type Entry

type Entry struct {
	Time          time.Time
	CorrelationID string
	UserID        uint
	HTTP          HTTPEntry
}

Entry holds all information related to an API call event.

type ErrorHandler

type ErrorHandler = common.ErrorHandler

ErrorHandler is the fundamental interface for error handling.

type HTTPEntry

type HTTPEntry struct {
	ClientIP     string
	UserAgent    string
	Method       string
	Path         string
	RequestBody  string
	StatusCode   int
	ResponseTime int
	ResponseSize int
	Errors       []string
}

HTTPEntry contains details related to an HTTP call for an audit log entry.

type NoopErrorHandler

type NoopErrorHandler = common.NoopErrorHandler

NoopErrorHandler is an error handler that discards every error.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures an audit log middleware.

func WithClock

func WithClock(clock Clock) Option

WithClock sets the clock in an audit log middleware.

func WithErrorHandler

func WithErrorHandler(errorHandler ErrorHandler) Option

WithErrorHandler sets the clock in an audit log middleware.

func WithSensitivePaths

func WithSensitivePaths(sensitivePaths []*regexp.Regexp) Option

WithSensitivePaths marks API call paths as sensitive, causing the log entry to omit the request body.

func WithUserIDExtractor

func WithUserIDExtractor(userIDExtractor func(req *http.Request) uint) Option

WithUserIDExtractor sets the function that extracts the user ID from the request.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier