auth

package
v0.0.0-...-2608e31 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MEMORY      = 64 * 1024
	ITERATIONS  = 3
	PARALLELISM = 2
	SALTLENGTH  = 16
	KEYLENGTH   = 32
)

Variables

This section is empty.

Functions

func CheckCurrentUser

func CheckCurrentUser(config *apiConfig.Config, mongo *database.MongoDB) gin.HandlerFunc

func ComparePasswordAndHash

func ComparePasswordAndHash(password string, encodedHash string) (bool, error)

func CreateSuperuser

func CreateSuperuser(mongo *database.MongoDB, email string)

func GenerateFromPassword

func GenerateFromPassword(password string) (string, error)

func GenerateRandomBytes

func GenerateRandomBytes(n uint32) ([]byte, error)

func GenerateRandomPassword

func GenerateRandomPassword(i int) string

func GenerateRoutes

func GenerateRoutes(relativePath string, r *gin.Engine, handler *Handler)

func GenerateToken

func GenerateToken(ttl time.Duration, payload JWTData, JWTSecretKey string) (string, error)

func ResetSuperuserPassword

func ResetSuperuserPassword(mongo *database.MongoDB, email string)

Types

type Argon

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

type ChangePasswordRequest

type ChangePasswordRequest struct {
	OldPassword string `json:"old_password" binding:"required"`
	Password    string `json:"password" binding:"required"`
	Password2   string `json:"password2" binding:"required"`
}

type Handler

type Handler struct {
	Config  *apiConfig.Config
	MongoDB *database.MongoDB
}

func NewAuthHandler

func NewAuthHandler(config *apiConfig.Config, mongo *database.MongoDB) *Handler

func (*Handler) ChangePassword

func (h *Handler) ChangePassword(c *gin.Context)

func (*Handler) Login

func (h *Handler) Login(c *gin.Context)

func (*Handler) Me

func (h *Handler) Me(c *gin.Context)

type JWTClaims

type JWTClaims struct {
	Data JWTData `json:"data"`
	jwt.StandardClaims
}

func ValidateToken

func ValidateToken(tokenString string, JWTSecretKey string) (JWTClaims, error)

type JWTData

type JWTData struct {
	Email  string `json:"email"`
	Client string `json:"client"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required"`
}

Jump to

Keyboard shortcuts

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