auth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("token is invalid")
	ErrExpiredToken = errors.New("token has expired")
)

Functions

func CheckPassword

func CheckPassword(password string, hashedPassword string) error

CheckPassword checks if the provided password is correct or not.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns the bcrypt hash of the password.

Types

type Claims

type Claims struct {
	UserID string `json:"user_id"`
	Email  string `json:"email"`
	jwt.RegisteredClaims
}

type JWTMaker

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

func (*JWTMaker) CreateToken

func (maker *JWTMaker) CreateToken(userID pgtype.UUID, email string, duration time.Duration) (string, error)

func (*JWTMaker) VerifyToken

func (maker *JWTMaker) VerifyToken(tokenString string) (*Claims, error)

type TokenMaker

type TokenMaker interface {
	CreateToken(userID pgtype.UUID, email string, duration time.Duration) (string, error)
	VerifyToken(token string) (*Claims, error)
}

func NewJWTMaker

func NewJWTMaker(secretKey string) (TokenMaker, error)

Jump to

Keyboard shortcuts

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