utils

package
v0.0.0-...-7b9a92c Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePasswords

func ComparePasswords(hashedPwd, inputPwd string) bool

ComparePasswords func for a comparing password.

func ConnectionURLBuilder

func ConnectionURLBuilder(n string) (string, error)

ConnectionURLBuilder func for building URL connection.

func GeneratePassword

func GeneratePassword(p string) string

GeneratePassword func for a making hash & salt with user password.

func GetCredentialsByRole

func GetCredentialsByRole(role string) ([]string, error)

GetCredentialsByRole func for getting credentials from a role name.

func NewValidator

func NewValidator() *validator.Validate

NewValidator func for create a new validator for model fields.

func NormalizePassword

func NormalizePassword(p string) []byte

NormalizePassword func for a returning the users input as a byte slice.

func ParseRefreshToken

func ParseRefreshToken(refreshToken string) (int64, error)

ParseRefreshToken func for parse second argument from refresh token.

func StartServer

func StartServer(a *fiber.App)

StartServer func for starting a simple server.

func StartServerWithGracefulShutdown

func StartServerWithGracefulShutdown(a *fiber.App)

StartServerWithGracefulShutdown function for starting server with a graceful shutdown.

func ValidatorErrors

func ValidatorErrors(err error) map[string]string

ValidatorErrors func for show validation errors for each invalid fields.

func VerifyRole

func VerifyRole(role string) (string, error)

VerifyRole func for verifying a given role.

Types

type TokenMetadata

type TokenMetadata struct {
	UserID      uuid.UUID
	Credentials map[string]bool
	Expires     int64
}

TokenMetadata struct to describe metadata in JWT.

func ExtractTokenMetadata

func ExtractTokenMetadata(c *fiber.Ctx) (*TokenMetadata, error)

ExtractTokenMetadata func to extract metadata from JWT.

type Tokens

type Tokens struct {
	Access  string
	Refresh string
}

Tokens struct to describe tokens object.

func GenerateNewTokens

func GenerateNewTokens(id string, credentials []string) (*Tokens, error)

GenerateNewTokens func for generate a new Access & Refresh tokens.

Jump to

Keyboard shortcuts

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