audit

package
v6.2.12 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CryptoNewKeyEvent occurs when creating a new key.
	CryptoNewKeyEvent = "CreateNewKey"
	// CryptoDeleteKeyEvent occurs when deleting a key.
	CryptoDeleteKeyEvent = "DeleteKey"
	// CryptoSignJWTEvent occurs when signing a JWT.
	CryptoSignJWTEvent = "SignJWT"
	// CryptoSignJWSEvent occurs when signing a JWS.
	CryptoSignJWSEvent = "SignJWS"
	// CryptoEncryptJWEEvent occurs when encryping a JWE
	CryptoEncryptJWEEvent = "EncryptJWE"
	// CryptoDecryptJWEEvent occurs when decryping a JWE
	CryptoDecryptJWEEvent = "DecryptJWE"
	// AccessGrantedEvent occurs when access to a protected API endpoint was granted
	AccessGrantedEvent = "AccessGranted"
	// AccessDeniedEvent occurs when access to a protected API endpoint was denied
	AccessDeniedEvent = "AccessDenied"
	// AccessKeyRegisteredEvent occurs when an authorized key is registered for future authorization events
	AccessKeyRegisteredEvent = "AccessKeyRegistered"
	// InvalidOAuthTokenEvent occurs when a client presents an invalid (unknown/expired) OAuth2 token.
	InvalidOAuthTokenEvent = "InvalidOAuthToken"
	// VerifiableCredentialRetrievedEvent occurs when a VC is retrieved by the remote wallet.
	VerifiableCredentialRetrievedEvent = "VerifiableCredentialRetrievedEvent"
	// VerifiableCredentialRemovedEvent occurs when a VC is removed from a wallet.
	VerifiableCredentialRemovedEvent = "VerifiableCredentialRemovedEvent"
)
View Source
const TestActor = "test-actor"

Variables

This section is empty.

Functions

func AssertAuditInfo

func AssertAuditInfo(t *testing.T, ctx echo.Context, actor, module, operation string)

func Context

func Context(parent context.Context, actor, module, operationName string) context.Context

Context returns a child context of the given parent context, enriched with the auditable actor and performed operation.

func ContextWithAuditInfo

func ContextWithAuditInfo() gomock.Matcher

func Log

func Log(ctx context.Context, logger *logrus.Entry, eventName string) *logrus.Entry

Log logs the given message as an audit event. The context must contain audit information.

func Middleware

func Middleware(moduleName string) func(echo.HandlerFunc) echo.HandlerFunc

Middleware is like SetOnEchoContext but then as handler for server interfaces. The operation ID is derived from the last part of the request path.

func SetOnEchoContext

func SetOnEchoContext(echoCtx echo.Context, moduleName, operationID string)

SetOnEchoContext adds audit information to the Echo request context so that the audit logger can log it. It sets the following fields: - actor, which is the subject of the JWT. Falls back to the client IP address if no authentication is used. - moduleName, which is the module name of the interface that invoked the operation. - operationID, which is operation that invoked the operation.

func StrictMiddleware

func StrictMiddleware(next func(ctx echo.Context, args interface{}) (interface{}, error), moduleName, operationID string) func(ctx echo.Context, args interface{}) (interface{}, error)

StrictMiddleware is like SetOnEchoContext but then as handler for strict server interfaces.

func TestContext

func TestContext() context.Context

Types

type CapturedLog

type CapturedLog struct {
	Hook *test.Hook
}

func CaptureAuditLogs

func CaptureAuditLogs(t *testing.T) *CapturedLog

func CaptureLogs

func CaptureLogs(t *testing.T, logger *logrus.Logger) *CapturedLog

func (*CapturedLog) AssertContains

func (c *CapturedLog) AssertContains(t *testing.T, module string, event string, actor string, message string)

func (*CapturedLog) Contains

func (c *CapturedLog) Contains(t *testing.T, eventName string) bool

type Info

type Info struct {
	// Actor is the user or service that performed the operation.
	Actor string
	// Operation is the name of the operation that was performed.
	Operation string
}

Info provides contextual information for auditable events.

func InfoFromContext

func InfoFromContext(ctx context.Context) *Info

InfoFromContext extracts the audit info from the given context.

Jump to

Keyboard shortcuts

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