service

package
v1.6.34 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package service contains common functions used by the whole application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcHash added in v1.6.18

func CalcHash(plaintext, keyOptional []byte) ([]byte, error)

CalcHash generates a fixed-sized BLAKE2b-256 hash of the given text

func DecryptEmail added in v1.6.19

func DecryptEmail(emailNonce, emailCipher string) (email string, err error)

DecryptEmail returns the plaintext email from the given cipher and nonce

func DelMem2FA added in v1.6.1

func DelMem2FA(authID uint64)

DelMem2FA - delete secrets from memory

func GenerateCode added in v1.6.18

func GenerateCode(length int) (string, error)

GenerateCode generates a random alphanumeric code of the given length

func GetClaims added in v1.6.1

func GetClaims(c *gin.Context) middleware.MyCustomClaims

GetClaims - get JWT custom claims

func GetHash added in v1.6.18

func GetHash(dataIn []byte) (dataOut []byte, err error)

GetHash returns single or nested hash of the data

func GetUserByEmail

func GetUserByEmail(email string, decryptEmail bool) (*model.Auth, error)

GetUserByEmail fetches auth info by email or hash of the email

func IsTokenAllowed added in v1.6.9

func IsTokenAllowed(jti string) bool

IsTokenAllowed returns true when the token is not in the blacklist

Dependency: JWT, Redis database + enable 'INVALIDATE_JWT' in .env

func JWTBlacklistChecker added in v1.6.9

func JWTBlacklistChecker() gin.HandlerFunc

JWTBlacklistChecker validates a token against the blacklist

func RandomByte added in v1.6.18

func RandomByte(length int) ([]byte, error)

RandomByte returns a secure random byte slice of the given length

func SendEmail added in v1.6.1

func SendEmail(email string, emailType int, opts ...string) (bool, error)

SendEmail sends a verification/password recovery email if

- required by the application

- an external email service is configured

- a redis database is configured

{true, nil} => email delivered successfully

{false, nil} => email delivery not required/service not configured

{false, error} => email delivery failed

func Validate2FA added in v1.6.1

func Validate2FA(encryptedMessage []byte, issuer string, userInput string) ([]byte, string, error)

Validate2FA validates user-provided OTP

func ValidateAuthID added in v1.6.18

func ValidateAuthID(authID uint64) bool

ValidateAuthID - check whether authID is missing

func ValidateUserID added in v1.6.1

func ValidateUserID(authID uint64, email string) bool

ValidateUserID - check whether authID or email is missing

Types

type PostmarkParams added in v1.6.1

type PostmarkParams struct {
	ServerToken   string
	TemplateID    int64
	From          string
	To            string
	Tag           string
	TrackOpens    bool
	TrackLinks    string
	MessageStream string
	HTMLModel     map[string]interface{}
}

PostmarkParams - parameters for postmark email delivery service

Jump to

Keyboard shortcuts

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