jwtclaims

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims added in v1.9.10

type Claims struct {
	Username string   `json:"username"`
	Roles    []string `json:"roles,omitempty"`

	jwt.RegisteredClaims
	// contains filtered or unexported fields
}

Claims represents the claims in a JWT token

func (*Claims) HasRole added in v1.9.10

func (c *Claims) HasRole(role string) bool

HasRole checks if the Claims contains the specified role (with a lazy RoleSet cache)

type ClaimsWithRoles

type ClaimsWithRoles interface {
	HasRole(role string) bool
}

ClaimsWithRoles is an interface for any type that can check if it has a specific role

type RoleSet added in v1.9.10

type RoleSet map[string]struct{}

RoleSet represents a set of roles with O(1) membership checks

func NewRoleSet added in v1.9.10

func NewRoleSet(roles []string) RoleSet

NewRoleSet builds a RoleSet from a slice of roles, skipping empty strings

func (RoleSet) HasRole added in v1.9.10

func (rs RoleSet) HasRole(role string) bool

HasRole checks whether the role exists in the set

Jump to

Keyboard shortcuts

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