utils

package
v0.0.0-...-dcedfe7 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePasswords

func ComparePasswords(storedPassword string, suppliedPassword string) (bool, error)

ComparePasswords get the string password and hashed it with salt get from stored password and compare both hashed passwords

func GenerateIDToken

func GenerateIDToken(user *model.User, key *rsa.PrivateKey, exp int64) (string, error)

GenerateIDToken generates an AccessToken which is a jwt with myCustomClaims Could call this GenerateIDTokenString, but the signature makes this fairly clear

func GeneratePrivateKey

func GeneratePrivateKey(bitSize int) (*rsa.PrivateKey, error)

GeneratePrivateKey creates a RSA Private Key of specified byte size

func GeneratePublicKey

func GeneratePublicKey(rsaPublicKey *rsa.PublicKey) ([]byte, error)

GeneratePublicKey take a rsa.PublicKey and return bytes suitable for writing to .pub file returns in the format "ssh-rsa ..."

func GenerateRefreshToken

func GenerateRefreshToken(uid uuid.UUID, key string, exp int64) (*model.RefreshTokenData, error)

GenerateRefreshToken creates a refresh token The refresh token stores only the user's ID, a string

func HashPassword

func HashPassword(password string) (string, error)

HashPassword receive a string password and hash it with salt

func IsAllowedImageType

func IsAllowedImageType(mimeType string) bool

IsAllowedImageType determines if image is among types defined in map of allowed images

func ObjNameFromURL

func ObjNameFromURL(imageURL string) (string, error)

ObjNameFromURL get base image from given url

func ValidateIDToken

func ValidateIDToken(tokenString string, key *rsa.PublicKey) (*model.AccessTokenCustomClaims, error)

ValidateIDToken returns the token's claims if the token is valid

func ValidateRefreshToken

func ValidateRefreshToken(tokenString string, key string) (*model.RefreshTokenCustomClaims, error)

ValidateRefreshToken uses the secret key to validate a refresh token

Types

This section is empty.

Jump to

Keyboard shortcuts

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