security

package
v0.10.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRefreshToken = errors.New("invalid refresh token")

Functions

func GenerateUniqueOtpSecret

func GenerateUniqueOtpSecret(id uuid.UUID) string

func HashPassword

func HashPassword(password string) (string, error)

func NewJWT

func NewJWT(payload jwt.MapClaims, signingKey string, secondsDuration int64) (string, error)

func ParseJWT

func ParseJWT(token string, verificationKey string) (jwt.MapClaims, error)

func ValidatePassword

func ValidatePassword(hashPassword, password string) bool

Types

type Otp

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

func NewOtp

func NewOtp(opts OtpOptions) *Otp

func (*Otp) Generate

func (o *Otp) Generate(secret string) (string, error)

Todo: allow generate to take in optional secret in other to further personalize token generated for each user.

func (*Otp) GenerateUserPersonalKey

func (o *Otp) GenerateUserPersonalKey(secret string) string

func (*Otp) Validate

func (o *Otp) Validate(passcode string, secret string) bool

type OtpOptions

type OtpOptions struct {
	Secret string
	Period uint
}

Jump to

Keyboard shortcuts

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