otelaudit

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOtelAuditLogging

func NewOtelAuditLogging(logger *slog.Logger, otelConfig *OtelConfig) func(next http.Handler) http.Handler

NewMiddleware returns a middleware function to add OTEL audit logging.

func SendOtelAuditEvent

func SendOtelAuditEvent(logger *slog.Logger, otelConfig *OtelConfig, ctx context.Context, statusCode int, req *http.Request, errorMsg string)

SendOtelAuditEvent sends an OTEL audit event using the provided logger and configuration. This function replaces the method attached to loggingMiddleware.

Types

type Middleware

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

Middleware implements a separate OTEL audit middleware.

func (*Middleware) ServeHTTP

func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP wraps the request and triggers the audit event.

type OtelConfig

type OtelConfig struct {
	Client                    *audit.Client
	CustomOperationDescs      map[string]string
	CustomOperationCategories map[string]msgs.OperationCategory
	OperationAccessLevel      string
	// ExcludeAuditEvents maps an HTTP method to a list of URL substrings.
	// If any substring is present in the full request URL,
	// the audit event for that request will be excluded.
	ExcludeAuditEvents map[string][]string
}

Jump to

Keyboard shortcuts

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