Back to / pkg / jwtmanager

Package jwtmanager

Latest Go to latest

The highest tagged major version is .

Published: Jul 30, 2020 | License: MIT | Module:



var Cache *cache.Cache

Cache in memory temporary store for responses from /validate for jwt

var Sites []string

Sites added to VouchClaims

var StandardClaims jwt.StandardClaims

StandardClaims jwt.StandardClaims implementation

func Configure

func Configure()

Configure see main.go configure()

func CreateUserTokenString

func CreateUserTokenString(u structs.User, customClaims structs.CustomClaims, ptokens structs.PTokens) string

CreateUserTokenString converts user to signed jwt

func FindJWT

func FindJWT(r *http.Request) string

FindJWT look for JWT in Cookie, JWT Header, Authorization Header (OAuth2 Bearer Token) and Query String in that order

func JWTCacheHandler

func JWTCacheHandler(next http.Handler) http.Handler

JWTCacheHandler looks for a JWT and... returns a cached response or passes the JWT in the context tests for JWTCacheHandler are present in `handlers/validate_test.go` to avoid circular imports

func ParseTokenString

func ParseTokenString(tokenString string) (*jwt.Token, error)

ParseTokenString converts signed token to jwt struct

func SiteInToken

func SiteInToken(site string, token *jwt.Token) bool

SiteInToken searches does the token contain the site?

func TokenIsValid

func TokenIsValid(token *jwt.Token, err error) bool

TokenIsValid gett better error reporting

type VouchClaims

type VouchClaims struct {
	Username     string   `json:"username"`
	Sites        []string `json:"sites"` // tempting to make this a map but the array is fewer characters in the jwt
	CustomClaims map[string]interface{}
	PAccessToken string
	PIdToken     string

VouchClaims jwt Claims specific to vouch

func ClaimsFromJWT

func ClaimsFromJWT(jwt string) (*VouchClaims, error)

ClaimsFromJWT parse the jwt and return the claims

func PTokenClaims

func PTokenClaims(ptoken *jwt.Token) (*VouchClaims, error)

PTokenClaims get all the claims

func (*VouchClaims) SiteInClaims

func (claims *VouchClaims) SiteInClaims(site string) bool

SiteInClaims does the claim contain the value?

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier