Documentation
¶
Index ¶
- func GetCurrentUserFromContext(ctx context.Context) (*models.User, bool)
- func GetUserIDFromContext(ctx context.Context) (string, bool)
- func IsAdminFromContext(ctx context.Context) bool
- func NewAuthBridge(api huma.API, authService *services.AuthService, ...) func(ctx huma.Context, next func(huma.Context))
- type ContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCurrentUserFromContext ¶
GetCurrentUserFromContext retrieves the current user from the context.
func GetUserIDFromContext ¶
GetUserIDFromContext retrieves the user ID from the context.
func IsAdminFromContext ¶
IsAdminFromContext checks if the current user is an admin.
func NewAuthBridge ¶
func NewAuthBridge(api huma.API, authService *services.AuthService, apiKeyService *services.ApiKeyService, 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" )
Click to show internal directories.
Click to hide internal directories.