auth

package
v0.0.0-...-d6f4c82 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(requestUser *models.UserAuthentication) (int, string, time.Time)

Login method authenticate the user and provide JWT token

Types

type APIKeyMiddleware

type APIKeyMiddleware struct {
	Path string
	// contains filtered or unexported fields
}

APIKeyMiddleware is a simplified shared secret authentication for api requests

func (*APIKeyMiddleware) Middleware

func (akm *APIKeyMiddleware) Middleware(next http.Handler) http.Handler

Middleware function, which will be called for each api request

type Claims

type Claims struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

Claims a struct that will be encoded to a JWT. We add jwt.StandardClaims as an embedded type, to provide fields like expiry time

type JWTAuthentication

type JWTAuthentication struct {
	PublicKey *rsa.PublicKey
	// contains filtered or unexported fields
}

JWTAuthentication ...

func InitJWTAuthentication

func InitJWTAuthentication() *JWTAuthentication

InitJWTAuthentication method initialize the JWTAuthentication model

func (*JWTAuthentication) Authenticate

func (backend *JWTAuthentication) Authenticate(user *models.UserAuthentication) bool

Authenticate method used to authenticate the users

func (*JWTAuthentication) GenerateToken

func (backend *JWTAuthentication) GenerateToken(username string) (string, time.Time, error)

GenerateToken method generates the User JWT Token

func (*JWTAuthentication) ValidateToken

func (backend *JWTAuthentication) ValidateToken(token string) (int, bool)

ValidateToken ...

Jump to

Keyboard shortcuts

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