middleware

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package middleware provides Gin middleware for admin-api's route groups.

Index

Constants

View Source
const (

	// ActingUserSubKey is the gin.Context key write handlers read to get the
	// attributed acting user after WriteAuth has validated the request.
	ActingUserSubKey = "actingUserSub"
)

Variables

This section is empty.

Functions

func WriteAuth

func WriteAuth(client *authz.Client) gin.HandlerFunc

WriteAuth requires either a forwarded user bearer token carrying the admin role (verified against auth-api's /authz/check) or, as a legacy fallback during migration, a valid X-Internal-Service-Token header (compared constant-time against INTERNAL_SERVICE_TOKEN). The legacy fallback authorizes the request but has no verified user to attribute it to; callers using it must still send a value acting-user identity out of band until they migrate. On success, the acting user (from auth-api's verified token subject) is stashed on the context under ActingUserSubKey for handlers to attribute their audit records to.

Types

This section is empty.

Jump to

Keyboard shortcuts

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