Documentation ¶
Index ¶
- func FromHeader(ctx *context.Context) string
- func FromQuery(ctx *context.Context) string
- func Get(ctx *context.Context) *multi.MultiClaims
- func GetAuthorityId(ctx *context.Context) []string
- func GetAuthorityType(ctx *context.Context) int
- func GetCreationDate(ctx *context.Context) int64
- func GetExpiresIn(ctx *context.Context) int64
- func GetTenancyId(ctx *context.Context) uint
- func GetTenancyName(ctx *context.Context) string
- func GetUserId(ctx *context.Context) uint
- func GetUsername(ctx *context.Context) string
- func GetVerifiedToken(ctx *context.Context) []byte
- func IsAdmin(ctx *context.Context) bool
- func IsRole(ctx *context.Context, authorityType int) bool
- type TokenExtractor
- type Verifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromHeader ¶
FromHeader is a token extractor. It reads the token from the Authorization request header of form: Authorization: "Bearer {token}".
func FromQuery ¶
FromQuery is a token extractor. It reads the token from the "token" url query parameter.
func Get ¶
func Get(ctx *context.Context) *multi.MultiClaims
Get returns the claims decoded by a verifier.
func GetVerifiedToken ¶
Types ¶
type TokenExtractor ¶
TokenExtractor is a function that takes a context as input and returns a token. An empty string should be returned if no token found without additional information.
func FromJSON ¶
func FromJSON(jsonKey string) TokenExtractor
FromJSON is a token extractor. Reads a json request body and extracts the json based on the given field. The request content-type should contain the: application/json header value, otherwise this method will not try to read and consume the body.
type Verifier ¶
type Verifier struct { Extractors []TokenExtractor Validators []multi.TokenValidator ErrorHandler func(ctx *context.Context, err error) }
func NewVerifier ¶
func NewVerifier(validators ...multi.TokenValidator) *Verifier
func (*Verifier) RequestToken ¶
RequestToken extracts the token from the
func (*Verifier) Verify ¶
func (v *Verifier) Verify(validators ...multi.TokenValidator) context.Handler
func (*Verifier) VerifyToken ¶
func (v *Verifier) VerifyToken(token []byte, validators ...multi.TokenValidator) ([]byte, *multi.MultiClaims, error)