Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTokenMissing is the error value that it's returned when // a token is not found based on the token extractor. ErrTokenMissing = errors.New("required authorization token not found") )
Functions ¶
func FromAuthHeader ¶
FromAuthHeader is a "TokenExtractor" that takes a give context and extracts the JWT token from the Authorization header.
Types ¶
type CasdoorOptions ¶
type CasdoorOptions struct { casdoor.CasdoorOptions // The function that will be called when there's an error validating the token // Default value: ErrorHandler errorHandler // A function that extracts the token from the request // Default: FromAuthHeader (i.e., from Authorization header as bearer token) Extractor TokenExtractor }
type Middleware ¶
type Middleware struct {
Options CasdoorOptions
}
func GetCasdoorMiddleware ¶
func GetCasdoorMiddleware() *Middleware
func New ¶
func New(opts ...CasdoorOptions) *Middleware
func (*Middleware) CheckJWT ¶
func (m *Middleware) CheckJWT(ctx iris.Context) error
func (*Middleware) Get ¶
func (m *Middleware) Get(ctx iris.Context) *casdoorsdk.Claims
Get returns the user (&token) information for this client/request
func (*Middleware) GetUserClaims ¶
func (m *Middleware) GetUserClaims(ctx iris.Context) *casdoorsdk.Claims
func (*Middleware) Serve ¶
func (m *Middleware) Serve(ctx iris.Context)
Serve the middleware's action
type TokenExtractor ¶
TokenExtractor is a function that takes a context as input and returns either a token or an error. An error should only be returned if an attempt to specify a token was found, but the information was somehow incorrectly formed. In the case where a token is simply not present, this should not be treated as an error. An empty string should be returned in that case.
func FromFirst ¶
func FromFirst(extractors ...TokenExtractor) TokenExtractor
FromFirst returns a function that runs multiple token extractors and takes the first token it finds
func FromHeader ¶
func FromHeader(key string) TokenExtractor
FromHeader is a "TokenExtractor" that takes a give context and extracts the specified key value from header.
func FromParameter ¶
func FromParameter(param string) TokenExtractor
FromParameter returns a function that extracts the token from the specified query string parameter