auth

package
v0.0.0-...-15a51b0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthSchemaNone   = "None"
	AuthSchemaBasic  = "Basic"
	AuthSchemaBearer = "Bearer"
	AuthSchemaOther  = "Other"
)

Variables

This section is empty.

Functions

func New

func New(config ...Config) fiber.Handler

New auth middleware

Types

type AuthResult

type AuthResult struct {
	AuthSchema AuthSchema
	Token      jwt.Token
	User       *user.User
}

type AuthSchema

type AuthSchema string

type Config

type Config struct {
	// AuthSchemas to be used in the Authorization header.
	// Optional. Default: "Bearer, Basic".
	AuthSchemas []AuthSchema

	// Filter defines a function to skip middleware.
	// Optional. Default: nil
	Filter func(*fiber.Ctx) bool

	// SuccessHandler defines a function which is executed for a valid token.
	// Optional. Default: nil
	SuccessHandler fiber.Handler

	// ErrorHandler defines a function which is executed for an invalid token.
	// It may be used to define a custom JWT error.
	// Optional. Default: 401 Invalid or expired JWT
	ErrorHandler fiber.ErrorHandler

	NoneAuthHandler fiber.Handler

	JWTParseOptions []jwt.ParseOption

	// Signing key to validate token. Used as fallback if SigningKeys has length 0.
	// Required. This or SigningKeys.
	SigningKey jwk.Key

	// Signing method, used to check token signing method.
	// Optional. Default: "HS256".
	// Possible values: "HS256", "HS384", "HS512", "ES256", "ES384", "ES512", "RS256", "RS384", "RS512"
	SignatureAlgorithm jwa.SignatureAlgorithm

	// Context key to store user information from the token into context.
	// Optional. Default: "auth".
	ContextKey string

	// TokenLookup is a string in the form of "<source>:<name>" that is used
	// to extract token from the request.
	// Optional. Default value "header:Authorization".
	// Possible values:
	// - "header:<name>"
	// - "query:<name>"
	// - "param:<name>"
	// - "cookie:<name>"
	TokenLookup string
}

Config defines the config for BasicAuth middleware

Jump to

Keyboard shortcuts

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