login

package
v0.0.0-...-333ec09 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBPool *db.Pool

This package scoped globals don't look nice What is a better way of doing this?

Functions

func Handler

func Handler(c echo.Context) error

func JWTError

func JWTError(err error, c echo.Context) error

JWT custom error handler

Types

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

func (*Credentials) Validate

func (c *Credentials) Validate(dbp *pgxpool.Pool) (bool, db.User)

For security remap fields (for example imagine the target struct supports an isAdmin field which could cause privilege scalation) not required for read-only operations but using as example

cleanLogin := sanitizedLogin{
	Username: login.Username,
	Password: login.Password,
	isAdmin:  false,
}

Commenting out for now

type sanitizedLogin struct {
	Username string
	Password string
	isAdmin  bool
}

@TODO generate random keys for JWT signing for each login

type JWT

type JWT struct {
	ExpirationHours  int
	MiddleWareConfig middleware.JWTConfig
}
var J *JWT

func (JWT) Decode

func (j JWT) Decode(token *jwt.Token) JwtCustomClaims

func (JWT) Generate

func (j JWT) Generate(user *db.User) (string, error)

type JwtCustomClaims

type JwtCustomClaims struct {
	User db.User
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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