auditing

package
v0.11.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const (
	Exclude string = "exclude-from-auditing"
)

Variables

This section is empty.

Functions

func HttpFilter

func HttpFilter(a Auditing, logger *zap.SugaredLogger) restful.FilterFunction

func NewConnectInterceptor

func NewConnectInterceptor(a Auditing, logger *zap.SugaredLogger, shouldAudit func(fullMethod string) bool) connect.Interceptor

func StreamServerInterceptor

func StreamServerInterceptor(a Auditing, logger *zap.SugaredLogger, shouldAudit func(fullMethod string) bool) grpc.StreamServerInterceptor

func UnaryServerInterceptor

func UnaryServerInterceptor(a Auditing, logger *zap.SugaredLogger, shouldAudit func(fullMethod string) bool) grpc.UnaryServerInterceptor

Types

type Auditing

type Auditing interface {
	Index(Entry) error
}

func New

func New(c Config) (Auditing, error)

type Config

type Config struct {
	Component        string
	URL              string
	APIKey           string
	IndexPrefix      string
	RotationInterval Interval
	Keep             int64
	Log              *zap.SugaredLogger
}

type Entry

type Entry struct {
	Id        string // filled by the auditing driver
	Component string
	RequestId string `json:"rqid"`
	Type      EntryType
	Timestamp time.Time

	User   string
	Tenant string

	// For `EntryDetailHTTP` the HTTP method get, post, put, delete, ...
	// For `EntryDetailGRPC` unary, stream
	Detail EntryDetail
	// e.g. Request, Response, Error, Opened, Close
	Phase EntryPhase
	// For `EntryDetailHTTP` /api/v1/...
	// For `EntryDetailGRPC` /api.v1/... (the method name)
	Path         string
	ForwardedFor string
	RemoteAddr   string

	Body       any // JSON, string or numbers
	StatusCode int // only for `EntryDetailHTTP`

	// Internal errors
	Error error
}

type EntryDetail

type EntryDetail string
const (
	EntryDetailGRPCUnary  EntryDetail = "unary"
	EntryDetailGRPCStream EntryDetail = "stream"
)

type EntryPhase

type EntryPhase string
const (
	EntryPhaseRequest  EntryPhase = "request"
	EntryPhaseResponse EntryPhase = "response"
	EntryPhaseSingle   EntryPhase = "single"
	EntryPhaseError    EntryPhase = "error"
	EntryPhaseOpened   EntryPhase = "opened"
	EntryPhaseClosed   EntryPhase = "closed"
)

type EntryType

type EntryType string
const (
	EntryTypeHTTP  EntryType = "http"
	EntryTypeGRPC  EntryType = "grpc"
	EntryTypeEvent EntryType = "event"
)

type Interval

type Interval string
var (
	HourlyInterval  Interval = "@hourly"
	DailyInterval   Interval = "@daily"
	MonthlyInterval Interval = "@monthly"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL