Documentation
¶
Index ¶
- Constants
- Variables
- func GetRawToken(ctx context.Context) string
- func HasRole(ctx context.Context, role string) bool
- func IsAuthenticated(ctx context.Context) bool
- func JwtValidator(next http.Handler) http.Handler
- func PutClaims(ctx context.Context, claimsPtr *AllClaims) context.Context
- func PutRawToken(ctx context.Context, rawToken string) context.Context
- func Setup(publicKeyPEMs []string, username string, password string) error
- func Subject(ctx context.Context) string
- type AllClaims
- type CustomClaims
- type GlobalClaims
Constants ¶
View Source
const ( RawTokenKey ctxJwtKeyType = 0 ClaimsKey ctxJwtKeyType = 1 )
Variables ¶
View Source
var Now = time.Now
Now exported for testing
View Source
var RsaPublicKeys = make([]*rsa.PublicKey, 0)
Functions ¶
func GetRawToken ¶
GetRawToken returns the raw token from the given context if one is present.
Returns the empty string if the context contains no valid token.
func IsAuthenticated ¶
func PutClaims ¶
PutClaims places a raw token in the context under the correct key.
Returns a child context with the token set.
Exposed for testing only.
func PutRawToken ¶
PutRawToken places a raw token in the context under the correct key.
Returns a child context with the token set.
Exposed for testing only.
Types ¶
type AllClaims ¶
type AllClaims struct {
// maybe * ?
jwt.RegisteredClaims
CustomClaims
}
type CustomClaims ¶
type CustomClaims struct {
// add any custom claim fields here so you can parse them
Global GlobalClaims `json:"global"`
}
type GlobalClaims ¶
Click to show internal directories.
Click to hide internal directories.