Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewJWT ¶
func NewJWT(claims *CustomClaims, signingMethod jwt.SigningMethod) *jwt.Token
NewJWT returns a token given claims and a specified signing method
Types ¶
type CustomClaims ¶
type CustomClaims struct { /* _______StandardClaims:______________ Audience string `json:"aud,omitempty"` ExpiresAt int64 `json:"exp,omitempty"` Id string `json:"jti,omitempty"` IssuedAt int64 `json:"iat,omitempty"` Issuer string `json:"iss,omitempty"` NotBefore int64 `json:"nbf,omitempty"` Subject string `json:"sub,omitempty"` ______________________________________*/ jwt.StandardClaims Groups []string `json:"grps,omitempty"` }
CustomClaims represents claims we wish to make and verify with JWTs
func NewCustomClaims ¶
func NewCustomClaims(sub, aud, iss string, grps []string, lifetime time.Duration) *CustomClaims
NewCustomClaims returns a new CustomClaims object
func StdClaimsToCustomClaims ¶
func StdClaimsToCustomClaims(stdClaims *jwt.MapClaims) (*CustomClaims, error)
StdClaimsToCustomClaims populates a CustomClaims struct with a given map of std claims
func ValidateJWT ¶
func ValidateJWT(tkString, iss, aud, url string, grps []string) (*CustomClaims, error)
ValidateJWT returns the claims within a token as a CustomClaims obect and validates its fields
func (*CustomClaims) HasGroup ¶
func (c *CustomClaims) HasGroup(groupID string) bool
HasGroup returns true if a CustomClaims object contains a given group as part of its grp claims
Click to show internal directories.
Click to hide internal directories.