middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package middleware holds the request-context helpers handlers use to find the caller. Authentication itself is iam's httpauth (wired in internal/auth and internal/server); this package only translates its subject into LibraryZ's numeric user id.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsModerator

func IsModerator(ctx context.Context, db *gorm.DB, userID uint) (bool, error)

IsModerator reports whether the user currently holds the "moderator" role, read from the database (not the access token), for checks made inside services. An unknown user is simply not a moderator.

func ParseSubjectID

func ParseSubjectID(s string) (uint, bool)

ParseSubjectID is the inverse of SubjectID. It rejects anything that isn't a canonical, non-zero decimal (no sign, no leading zeros).

func SubjectID

func SubjectID(id uint) string

SubjectID is the iam subject id for a user id.

func UserID

func UserID(ctx context.Context) (uint, bool)

UserID returns the authenticated user's id, set by httpauth's Protect for a valid bearer access token.

Types

This section is empty.

Jump to

Keyboard shortcuts

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