middleware

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestID

func RequestID(next http.Handler) http.Handler

func RequireRole added in v0.1.2

func RequireRole(allowed ...string) func(http.Handler) http.Handler

RequireRole returns a middleware that allows only requests whose JWT role is one of the provided allowed roles.

func RequireTeamRole added in v0.1.9

func RequireTeamRole(allowed ...string) func(http.Handler) http.Handler

RequireTeamRole checks the caller's role within the team (from TeamMemberCtx) against the allowed roles. Must run after TeamAccessMiddleware.

func UserFromContext

func UserFromContext(ctx context.Context) (*security.RequestClaims, bool)

Types

type ActiveChecker added in v0.1.2

type ActiveChecker interface {
	IsUserActive(ctx context.Context, userID uuid.UUID) (bool, error)
}

ActiveChecker is implemented by the user service to verify a user is still active.

type AuthMiddleware

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

func NewAuthMiddleware

func NewAuthMiddleware(tokenSvc *security.TokenService, activeChecker ActiveChecker) *AuthMiddleware

func (*AuthMiddleware) Handle

func (a *AuthMiddleware) Handle(next http.Handler) http.Handler

type Middleware

type Middleware func(http.Handler) http.Handler

func Logger

func Logger(log *zerolog.Logger) Middleware

type TeamAccessMiddleware added in v0.1.9

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

func NewTeamAccess added in v0.1.9

func NewTeamAccess(teamSvc TeamMembershipChecker) *TeamAccessMiddleware

func (*TeamAccessMiddleware) Handle added in v0.1.9

func (t *TeamAccessMiddleware) Handle(next http.Handler) http.Handler

Handle validates that the authenticated user is an active member of the team identified by the {teamID} URL parameter and injects the membership into context.

type TeamMemberCtx added in v0.1.9

type TeamMemberCtx struct {
	MemberID uuid.UUID
	TeamID   uuid.UUID
	UserID   uuid.UUID
	Role     string
	IsActive bool
}

func TeamMemberFromContext added in v0.1.9

func TeamMemberFromContext(ctx context.Context) (*TeamMemberCtx, bool)

type TeamMembershipChecker added in v0.1.9

type TeamMembershipChecker interface {
	GetMembership(ctx context.Context, userID, teamID uuid.UUID) (TeamMemberCtx, error)
}

TeamMembershipChecker is implemented by the team service.

Jump to

Keyboard shortcuts

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