middleware

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentUserFromContext

func GetCurrentUserFromContext(ctx context.Context) (*models.User, bool)

GetCurrentUserFromContext retrieves the current user from the context.

func GetRemoteAddrFromContext added in v1.19.0

func GetRemoteAddrFromContext(ctx context.Context) string

GetRemoteAddrFromContext retrieves the request remote address from context.

func GetUserIDFromContext

func GetUserIDFromContext(ctx context.Context) (string, bool)

GetUserIDFromContext retrieves the user ID from the context.

func IsAdminFromContext

func IsAdminFromContext(ctx context.Context) bool

IsAdminFromContext checks if the current user is an admin.

func NewAuthBridge

func NewAuthBridge(api huma.API, authService *services.AuthService, apiKeyService *services.ApiKeyService, envTokenResolver environmentAccessTokenResolver, cfg *config.Config) func(ctx huma.Context, next func(huma.Context))

NewAuthBridge creates a Huma middleware that validates JWT tokens and enforces security requirements defined on operations.

Types

type ContextKey

type ContextKey string

ContextKey is a type for context keys used by Huma handlers.

const (
	// ContextKeyUserID is the context key for the authenticated user's ID.
	ContextKeyUserID ContextKey = "userID"
	// ContextKeyCurrentUser is the context key for the authenticated user model.
	ContextKeyCurrentUser ContextKey = "currentUser"
	// ContextKeyUserIsAdmin is the context key for whether the user is an admin.
	ContextKeyUserIsAdmin ContextKey = "userIsAdmin"
	// ContextKeyRemoteAddr is the context key for the request remote address.
	ContextKeyRemoteAddr ContextKey = "remoteAddr"
)

Jump to

Keyboard shortcuts

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