Documentation ¶
Overview ¶
Package service contains common functions used by the whole application
Index ¶
- func CalcHash(plaintext, keyOptional []byte) ([]byte, error)
- func DecryptEmail(emailNonce, emailCipher string) (email string, err error)
- func DelMem2FA(authID uint64)
- func GenerateCode(length int) (string, error)
- func GetClaims(c *gin.Context) middleware.MyCustomClaims
- func GetHash(dataIn []byte) (dataOut []byte, err error)
- func GetUserByEmail(email string, decryptEmail bool) (*model.Auth, error)
- func IsTokenAllowed(jti string) bool
- func JWTBlacklistChecker() gin.HandlerFunc
- func Postmark(params PostmarkParams) (postmark.EmailResponse, error)
- func RandomByte(length int) ([]byte, error)
- func SendEmail(email string, emailType int, opts ...string) (bool, error)
- func Validate2FA(encryptedMessage []byte, issuer string, userInput string) ([]byte, string, error)
- func ValidateAuthID(authID uint64) bool
- func ValidateUserID(authID uint64, email string) bool
- type PostmarkParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcHash ¶ added in v1.6.18
CalcHash generates a fixed-sized BLAKE2b-256 hash of the given text
func DecryptEmail ¶ added in v1.6.19
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
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 GetUserByEmail ¶
GetUserByEmail fetches auth info by email or hash of the email
func IsTokenAllowed ¶ added in v1.6.9
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 Postmark ¶ added in v1.6.1
func Postmark(params PostmarkParams) (postmark.EmailResponse, error)
Postmark email delivery service using HTML templates
https://postmarkapp.com/developer/api/email-api
https://postmarkapp.com/developer/api/templates-api
https://account.postmarkapp.com/servers/{ServerID}/templates
func RandomByte ¶ added in v1.6.18
RandomByte returns a secure random byte slice of the given length
func SendEmail ¶ added in v1.6.1
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
Validate2FA validates user-provided OTP
func ValidateAuthID ¶ added in v1.6.18
ValidateAuthID - check whether authID is missing
func ValidateUserID ¶ added in v1.6.1
ValidateUserID - check whether authID or email is missing