Documentation
¶
Index ¶
- Constants
- func AssertAuditInfo(t *testing.T, ctx echo.Context, actor, module, operation string)
- func Context(parent context.Context, actor, module, operationName string) context.Context
- func ContextWithAuditInfo() gomock.Matcher
- func Log(ctx context.Context, logger *logrus.Entry, eventName string) *logrus.Entry
- func Middleware(moduleName string) func(echo.HandlerFunc) echo.HandlerFunc
- func SetOnEchoContext(echoCtx echo.Context, moduleName, operationID string)
- func StrictMiddleware(next func(ctx echo.Context, args interface{}) (interface{}, error), ...) func(ctx echo.Context, args interface{}) (interface{}, error)
- func TestContext() context.Context
- type CapturedLog
- type Info
Constants ¶
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" )
const TestActor = "test-actor"
Variables ¶
This section is empty.
Functions ¶
func AssertAuditInfo ¶
func Context ¶
Context returns a child context of the given parent context, enriched with the auditable actor and performed operation.
func ContextWithAuditInfo ¶
func Log ¶
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 ¶
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 ¶
Types ¶
type CapturedLog ¶
func CaptureAuditLogs ¶
func CaptureAuditLogs(t *testing.T) *CapturedLog
func CaptureLogs ¶
func CaptureLogs(t *testing.T, logger *logrus.Logger) *CapturedLog
func (*CapturedLog) AssertContains ¶
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 ¶
InfoFromContext extracts the audit info from the given context.