authentication

package
v0.0.0-...-e5c7075 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

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

Claims is a struct that is consumed by the jwt-go that includes the claims that need to be included into a json web token.

type JwtAuth

type JwtAuth struct {
	// contains filtered or unexported fields
}

JwtAuth is a struct holding the jwtKey. The key is generated once when starting the middleware.

func NewJwtAuth

func NewJwtAuth() (*JwtAuth, error)

NewJwtAuth returns a new JwtAuth struct if the jwt key generation is successful, or an error, if it is not.

func (*JwtAuth) GenerateToken

func (jwtAuth *JwtAuth) GenerateToken(username string) (string, error)

GenerateToken generates a jwt token. It is the callers job to ensure that the username has been verified in the database first.

func (*JwtAuth) ValidateToken

func (jwtAuth *JwtAuth) ValidateToken(tokenStr string) error

ValidateToken takes a jwt token string as an argument and returns an error if the validation fails. If the validation is successful, nil is returned

Jump to

Keyboard shortcuts

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