Documentation
¶
Index ¶
- func RequestID(next http.Handler) http.Handler
- func RequireRole(allowed ...string) func(http.Handler) http.Handler
- func RequireTeamRole(allowed ...string) func(http.Handler) http.Handler
- func UserFromContext(ctx context.Context) (*security.RequestClaims, bool)
- type ActiveChecker
- type AuthMiddleware
- type Middleware
- type TeamAccessMiddleware
- type TeamMemberCtx
- type TeamMembershipChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequireRole ¶ added in v0.1.2
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
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
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
type Middleware ¶
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
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.
Click to show internal directories.
Click to hide internal directories.