v1

package
v0.0.0-...-236fc01 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIKeyHeader = "X-Api-Key"
)

Functions

func Authorizator

func Authorizator(data interface{}, c *gin.Context) bool

func GenerateAPIKey

func GenerateAPIKey(n int) (string, error)

func HashSHA512

func HashSHA512(str string) string

func IdentityHandler

func IdentityHandler(c *gin.Context) interface{}

func PayloadFunc

func PayloadFunc(data interface{}) jwt.MapClaims

func Unauthorized

func Unauthorized(c *gin.Context, code int, message string)

Types

type APIKey

type APIKey struct {
	HeaderName string
	DbClient   *database.Client
}

func NewAPIKey

func NewAPIKey(dbClient *database.Client) *APIKey

func (*APIKey) MiddlewareFunc

func (a *APIKey) MiddlewareFunc() gin.HandlerFunc

type JWT

type JWT struct {
	Middleware *jwt.GinJWTMiddleware
	DbClient   *database.Client
}

func NewJWT

func NewJWT(dbClient *database.Client) (*JWT, error)

func (*JWT) Authenticator

func (j *JWT) Authenticator(c *gin.Context) (interface{}, error)

type Middlewares

type Middlewares struct {
	APIKey *APIKey
	JWT    *JWT
}

func NewMiddlewares

func NewMiddlewares(dbClient *database.Client) (*Middlewares, error)

Jump to

Keyboard shortcuts

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