auditor

package
v0.146.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AuditEventType = "AUDIT_EVENT"

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorType

type ActorType string

ActorType is the type for the actor of a log entry, meaning the user or service that performed the action.

const (
	// ActorTypeUser is the type for a user actor.
	ActorTypeUser ActorType = "USER"
	// ActorTypeAPIToken is the type for am API Token actor.
	ActorTypeAPIToken ActorType = "API_TOKEN"
	// ActorTypeSystem is the type for a system actor.
	ActorTypeSystem = "SYSTEM"
)

type AuditEventPayload

type AuditEventPayload struct {
	ActionType  string
	TargetType  TargetType
	TargetID    *uuid.UUID
	ActorType   ActorType
	ActorID     *uuid.UUID
	ActorEmail  string
	OrgID       *uuid.UUID
	Description string
	Info        json.RawMessage
	Digest      *cr_v1.Hash
}

type AuditLogPublisher

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

func NewAuditLogPublisher

func NewAuditLogPublisher(conn *nats.Conn, logger log.Logger) (*AuditLogPublisher, error)

func (*AuditLogPublisher) Publish

func (n *AuditLogPublisher) Publish(data *EventPayload) error

type DescriptionVariables

type DescriptionVariables struct {
	ActorType  ActorType
	ActorID    *uuid.UUID
	ActorEmail string
	OrgID      *uuid.UUID
}

type EventPayload

type EventPayload struct {
	EventType string // AUDIT_EVENT
	Timestamp time.Time
	Data      *AuditEventPayload
}

func GenerateAuditEvent

func GenerateAuditEvent(entry LogEntry, opts ...GeneratorOption) (*EventPayload, error)

func (*EventPayload) ToJSON

func (e *EventPayload) ToJSON() ([]byte, error)

type GeneratorOption

type GeneratorOption func(*GeneratorOptions) error

func WithActor

func WithActor(actorType ActorType, actorID uuid.UUID, email string) GeneratorOption

func WithOrgID

func WithOrgID(orgID uuid.UUID) GeneratorOption

type GeneratorOptions

type GeneratorOptions struct {
	ActorType  ActorType
	ActorID    *uuid.UUID
	ActorEmail string
	OrgID      *uuid.UUID
}

type LogEntry

type LogEntry interface {
	// ActionType returns the type of the action performed.
	ActionType() string
	// ActionInfo returns the information about the action performed.
	ActionInfo() (json.RawMessage, error)
	// TargetType returns the type of the target of the action.
	TargetType() TargetType
	// TargetID returns the ID of the target of the action.
	TargetID() *uuid.UUID
	// Description returns a templatable string, see the DescriptionVariables struct.
	Description() string
	RequiresActor() bool
}

LogEntry is the interface for all log entries. All events should implement this interface to be able to be logged.

type TargetType

type TargetType string

TargetType is the type for the target of a log entry, aka the resource acted upon.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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