auditrecord

package
v0.76.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIdempotencyKeyConflict = errors.New("audit record already exists for the given idempotency key")
	ErrInvalidUUID            = errors.New("invalid syntax of uuid")
	ErrNotFound               = errors.New("audit record not found")
	ErrRepositoryBadInput     = errors.New("invalid repository input")
	ErrActorNotFound          = errors.New("actor not found")
)

Functions

func SetAuditRecordActorContext added in v0.76.0

func SetAuditRecordActorContext(ctx context.Context, actor Actor) context.Context

SetAuditRecordActorContext sets the audit record actor in context It accepts an Actor struct but stores it as a map to avoid layer violations in repositories

Types

type Actor

type Actor struct {
	ID       string            `json:"id"`
	Type     string            `json:"type"`
	Name     string            `json:"name"`
	Metadata metadata.Metadata `json:"metadata"`
}

type AuditRecord

type AuditRecord struct {
	ID             string            `json:"id,omitempty"`
	Event          string            `json:"event"`
	Actor          Actor             `json:"actor"`
	Resource       Resource          `json:"resource"`
	Target         *Target           `json:"target"`
	OccurredAt     time.Time         `json:"occurred_at"`
	OrgID          string            `json:"org_id"`
	RequestID      *string           `json:"request_id"`
	CreatedAt      time.Time         `json:"created_at,omitempty"`
	Metadata       metadata.Metadata `json:"metadata"`
	IdempotencyKey string            `json:"idempotency_key"`
}

type AuditRecordRQLSchema added in v0.75.0

type AuditRecordRQLSchema struct {
	ID             string    `rql:"name=id,type=string"`
	Event          string    `rql:"name=event,type=string"`
	ActorID        string    `rql:"name=actor_id,type=string"`
	ActorType      string    `rql:"name=actor_type,type=string"`
	ActorName      string    `rql:"name=actor_name,type=string"`
	ResourceID     string    `rql:"name=resource_id,type=string"`
	ResourceType   string    `rql:"name=resource_type,type=string"`
	ResourceName   string    `rql:"name=resource_name,type=string"`
	TargetID       string    `rql:"name=target_id,type=string"`
	TargetType     string    `rql:"name=target_type,type=string"`
	TargetName     string    `rql:"name=target_name,type=string"`
	OccurredAt     time.Time `rql:"name=occurred_at,type=datetime"`
	OrgID          string    `rql:"name=org_id,type=string"`
	RequestID      string    `rql:"name=request_id,type=string"`
	CreatedAt      time.Time `rql:"name=created_at,type=datetime"`
	IdempotencyKey string    `rql:"name=idempotency_key,type=string"`
}

AuditRecordRQLSchema is the schema for audit record RQL queries. This is a flattened version of the AuditRecord struct. This is needed because the RQL parser does not support nested structs.

type AuditRecordsList added in v0.75.0

type AuditRecordsList struct {
	AuditRecords []AuditRecord
	Group        *utils.Group
	Page         utils.Page
}

type Repository

type Repository interface {
	Create(ctx context.Context, auditRecord AuditRecord) (AuditRecord, error)
	GetByIdempotencyKey(ctx context.Context, idempotencyKey string) (AuditRecord, error)
	List(ctx context.Context, query *rql.Query) (AuditRecordsList, error)
	Export(ctx context.Context, query *rql.Query) (io.Reader, string, error)
}

type Resource

type Resource struct {
	ID       string            `json:"id"`
	Type     string            `json:"type"`
	Name     string            `json:"name"`
	Metadata metadata.Metadata `json:"metadata"`
}

type Service

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

func NewService

func NewService(repository Repository, userService UserService, serviceUserService ServiceUserService, sessionService SessionService) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, auditRecord AuditRecord) (AuditRecord, bool, error)

func (*Service) Export added in v0.75.0

func (s *Service) Export(ctx context.Context, query *rql.Query) (io.Reader, string, error)

func (*Service) List added in v0.75.0

func (s *Service) List(ctx context.Context, query *rql.Query) (AuditRecordsList, error)

type ServiceUserService

type ServiceUserService interface {
	Get(ctx context.Context, id string) (serviceuser.ServiceUser, error)
}

type SessionService added in v0.75.0

type SessionService interface {
	Get(ctx context.Context, id uuid.UUID) (*frontiersession.Session, error)
}

type Target

type Target struct {
	ID       string            `json:"id"`
	Type     string            `json:"type"`
	Name     string            `json:"name"`
	Metadata metadata.Metadata `json:"metadata"`
}

type UserService

type UserService interface {
	GetByID(ctx context.Context, id string) (userpkg.User, error)
	IsSudo(ctx context.Context, id string, permissionName string) (bool, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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