audit

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfKey = "audit"
)

Variables

View Source
var (
	ErrIteratorClosed = errors.New("iterator closed")
)

Functions

func NewContextWithCallID

func NewContextWithCallID(ctx context.Context, id ID) context.Context

func NewUnaryInterceptor

func NewUnaryInterceptor(log Log, exclude ExcludeMethod) grpc.UnaryServerInterceptor

func PeerFromContext

func PeerFromContext(ctx context.Context) *auditv1.Peer

func RegisterBackend

func RegisterBackend(name string, cons Constructor)

RegisterBackend registers an audit log backend.

Types

type AccessLogEntryMaker

type AccessLogEntryMaker func() (*auditv1.AccessLogEntry, error)

AccessLogEntryMaker is a lazy constructor for access log entries.

type AccessLogIterator

type AccessLogIterator interface {
	Next() (*auditv1.AccessLogEntry, error)
}

type Conf

type Conf struct {
	// contains filtered or unexported fields
}

func (*Conf) Key

func (c *Conf) Key() string

func (*Conf) SetDefaults

func (c *Conf) SetDefaults()

func (*Conf) UnmarshalYAML added in v0.7.0

func (c *Conf) UnmarshalYAML(unmarshal func(interface{}) error) error

type Constructor

type Constructor func(context.Context) (Log, error)

Constructor for backends.

type DecisionLogEntryMaker

type DecisionLogEntryMaker func() (*auditv1.DecisionLogEntry, error)

DecisionLogEntryMaker is a lazy constructor for decision log entries.

type DecisionLogIterator

type DecisionLogIterator interface {
	Next() (*auditv1.DecisionLogEntry, error)
}

type ExcludeMethod

type ExcludeMethod func(string) bool

type ID

type ID string

func CallIDFromContext

func CallIDFromContext(ctx context.Context) (ID, bool)

func FromRepr

func FromRepr(id IDBytes) ID

FromRepr converts the byte representation to a string ID.

func NewID

func NewID() (ID, error)

NewID generates a new ULID using the current time.

func NewIDForTS

func NewIDForTS(ts uint64) (ID, error)

NewIDForTS generates a new ULID for the given timestamp.

func NewIDForTime

func NewIDForTime(ts time.Time) (ID, error)

NewIDForTime generates a new ULID using the given time.

func (ID) Repr

func (id ID) Repr() (IDBytes, error)

type IDBytes

type IDBytes = ulid.ULID

type IDGen

type IDGen struct {
	// contains filtered or unexported fields
}

IDGen is a generator for ULIDs without the monotonicity guarantee. Monotonicity adds overhead that we don't really need because approximate order is good enough for decision logs.

func NewIDGen

func NewIDGen(poolSize uint64, randSeed int64) *IDGen

func (*IDGen) New

func (ug *IDGen) New() (ID, error)

New generates a new ULID using the current time.

func (*IDGen) NewForTS

func (ug *IDGen) NewForTS(ts uint64) (ID, error)

NewForTS generates a new ULID for the given timestamp.

func (*IDGen) NewForTime

func (ug *IDGen) NewForTime(ts time.Time) (ID, error)

NewForTime generates a new ULID using the given time.

type Log

type Log interface {
	WriteAccessLogEntry(context.Context, AccessLogEntryMaker) error
	WriteDecisionLogEntry(context.Context, DecisionLogEntryMaker) error
	LastNAccessLogEntries(context.Context, uint) AccessLogIterator
	LastNDecisionLogEntries(context.Context, uint) DecisionLogIterator
	AccessLogEntriesBetween(context.Context, time.Time, time.Time) AccessLogIterator
	DecisionLogEntriesBetween(context.Context, time.Time, time.Time) DecisionLogIterator
	AccessLogEntryByID(context.Context, ID) AccessLogIterator
	DecisionLogEntryByID(context.Context, ID) DecisionLogIterator
	Close()
}

func NewLog

func NewLog(ctx context.Context) (Log, error)

NewLog creates a new audit log.

func NewNopLog

func NewNopLog() Log

NewNopLog returns an audit log that does nothing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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