iris

package
v0.0.1-alpha3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromHeader

func FromHeader(ctx *context.Context) string

FromHeader is a token extractor. It reads the token from the Authorization request header of form: Authorization: "Bearer {token}".

func FromQuery

func FromQuery(ctx *context.Context) string

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 GetAuthorityId

func GetAuthorityId(ctx *context.Context) []string

GetAuthorityId 角色id

func GetAuthorityType

func GetAuthorityType(ctx *context.Context) int

GetAuthorityType 角色类型

func GetCreationDate

func GetCreationDate(ctx *context.Context) int64

GetCreationDate 登录时间

func GetExpiresIn

func GetExpiresIn(ctx *context.Context) int64

GetExpiresIn 有效期

func GetTenancyId

func GetTenancyId(ctx *context.Context) uint

GetTenancyId 商户id

func GetTenancyName

func GetTenancyName(ctx *context.Context) string

GetTenancyName 商户名称

func GetUserId

func GetUserId(ctx *context.Context) uint

GetUserId 用户id

func GetUsername

func GetUsername(ctx *context.Context) string

GetUsername 用户名

func GetVerifiedToken

func GetVerifiedToken(ctx *context.Context) []byte

func IsAdmin

func IsAdmin(ctx *context.Context) bool

func IsGeneral

func IsGeneral(ctx *context.Context) bool

func IsTenancy

func IsTenancy(ctx *context.Context) bool

Types

type TokenExtractor

type TokenExtractor func(*context.Context) string

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

func (v *Verifier) RequestToken(ctx *context.Context) (token string)

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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