utils

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDTokenSubject     = "ID_TOKEN"
	AccessTokenSubject = "ACCESS_TOKEN"
)

Variables

This section is empty.

Functions

func Check

func Check(f func() error)

Check - use to fix GoMetaLinter warning of error not check

func GenerateEncryptedPassword

func GenerateEncryptedPassword(password []byte) (string, error)

GenerateEncryptedPassword returns encryptedly securely generated string.

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(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string.

func GetGender

func GetGender(s string) null.String

GetGender format the gender string

func InitDB

func InitDB(attempts, retryMaxDelay int) (*gorm.DB, error)

InitDB initiates the MySQL database connection

func InitMongoDB

func InitMongoDB() (*mgo.Session, error)

InitMongoDB initiates the Mongo DB connection

func RetrieveMailServiceAccessToken

func RetrieveMailServiceAccessToken(expiration int) (string, error)

RetrieveMailServiceAccessToken generate JWT for mail service validation

func RetrieveV1Token

func RetrieveV1Token(userID uint, email string) (string, error)

func RetrieveV2AccessToken

func RetrieveV2AccessToken(userID uint, email string, expiration int) (string, error)

func RetrieveV2IDToken

func RetrieveV2IDToken(userID uint, email, firstName, lastName string, expiration int) (string, error)

Types

type AccessTokenJWTClaims

type AccessTokenJWTClaims struct {
	UserID uint   `json:"user_id"`
	Email  string `json:"email"`
	jwt.StandardClaims
}

type AuthTokenType

type AuthTokenType int
const (
	AuthV1Token AuthTokenType = iota + 1

	AuthV2IDToken
	AuthV2AccessToken
)

type IDTokenJWTClaims

type IDTokenJWTClaims struct {
	UserID    uint   `json:"user_id"`
	Email     string `json:"email"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	jwt.StandardClaims
}

IDToken

func (IDTokenJWTClaims) Valid

func (idc IDTokenJWTClaims) Valid() error

type ReporterJWTClaims

type ReporterJWTClaims struct {
	UserID uint   `json:"user_id"`
	Email  string `json:"email"`
	jwt.StandardClaims
}

ReporterJWTClaims JWT claims we used

Jump to

Keyboard shortcuts

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