authpro

package module
v0.0.0-...-aa076f6 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 18 Imported by: 0

README

Authpro

Documentation

Index

Constants

View Source
const (
	Content  = "Content-Type"
	AppJson  = "application/json"
	RandChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
)

Variables

This section is empty.

Functions

func DotENV

func DotENV()

Types

type Auth

type Auth interface {
	TokenJWT(claimName string, userId uuid.UUID) (string, string, error)
	ParseJWT(claimName string, tokenString string) (string, float64, error)
	ExtractJWT() (string, error)
	MiddlewarePerm(claimName string) bool
	HashPassword(password string) ([]byte, error)
	ComparePassword(userPassword []byte, dtoPassword string) error
	RandomPassword(length int) (string, error)
	UUID(param string) (uuid.UUID, error)
	MiddlewareApiKey(apiKeyName, apiValueName string, r *http.Request) (bool, string)
}

func NewAuth

func NewAuth(w http.ResponseWriter, r *http.Request) Auth

type PasetoMaker

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

func NewPasetoMaker

func NewPasetoMaker(symmetricKey string) (*PasetoMaker, error)

func (*PasetoMaker) CreatePasetoToken

func (maker *PasetoMaker) CreatePasetoToken(userID uuid.UUID, duration time.Duration) (string, error)

func (*PasetoMaker) VerifyPasetoToken

func (maker *PasetoMaker) VerifyPasetoToken(token string) (*Payload, error)

type Payload

type Payload struct {
	ID        uuid.UUID `json:"ID"`
	UserID    uuid.UUID `json:"userID"`
	IssuedAt  time.Time `json:"issued_at"`
	ExpiredAt time.Time `json:"expired_at"`
}

func NewPasetoPayload

func NewPasetoPayload(userID uuid.UUID, duration time.Duration) (*Payload, error)

func (*Payload) Valid

func (payload *Payload) Valid() error

Jump to

Keyboard shortcuts

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