utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

auth/tokens.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAccessToken

func GenerateAccessToken(userID string, duration time.Duration, secretKey string) (string, error)

func GenerateBase64Token

func GenerateBase64Token(length int) (string, error)

GenerateBase64Token generates a random base64 encoded token

func GenerateRandomToken

func GenerateRandomToken(length int) (string, error)

GenerateRandomToken generates a random token with the specified length in bytes

func GenerateRefreshToken

func GenerateRefreshToken() (string, error)

func GenerateTokens

func GenerateTokens(userID string, accessTokenttl time.Duration, refreshTokenTTl time.Duration, secret string) (accessToken string, refreshToken string, err error)

GenerateTokens creates a new JWT access token and refresh token

func HashPassword

func HashPassword(password string) (string, error)

HashPassword creates a bcrypt hash of the password

func ValidatePassword

func ValidatePassword(hashedPassword, password string) error

ValidatePassword checks if the provided password is correct

func ValidateToken

func ValidateToken(tokenString string, secret string) (jwt.MapClaims, error)

ValidateToken validates a JWT token

Types

This section is empty.

Jump to

Keyboard shortcuts

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