utils

package
v0.0.0-...-37d38c9 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAndCreateDataDirectory

func CheckAndCreateDataDirectory()

CheckAndCreateDataDirectory creates the data directory if it doesn't exist

func GenerateJWT

func GenerateJWT(user models.User, jwtSecret string) (string, error)

GenerateJWT generates a JWT for the given user with 1hr validity

func GenerateLoginTokens

func GenerateLoginTokens(user models.User, jwtSecret string) (at, rt string, err error)

GenerateLoginTokens creates a JWT with 1 hour validity and a refresh token (which is synced with the DB) Returns (access token, refresh token, error)

func GenerateRandomBytes

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

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomStringURLSafe

func GenerateRandomStringURLSafe(n int) (string, error)

GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func VerifyRefreshToken

func VerifyRefreshToken(refreshToken string) (valid bool, username string, err error)

VerifyRefreshToken is used to verify if the refresh token is valid or not

Types

This section is empty.

Jump to

Keyboard shortcuts

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