common

package
v0.0.0-...-48f0708 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const NBRandomPassword = "A String Very Very Very Niubilty!!@##$!@#4"

NBRandomPassword : random password

View Source
const NBSecretPassword = "A String Very Very Very Strong!!@##$!@#$"

NBSecretPassword : secret password

Variables

MoDB : reference to mongodb client

View Source
var RedisClient *redis.Client

RedisClient ...

Functions

func Bind

func Bind(c *gin.Context, obj interface{}) error

Bind :

func CompareData

func CompareData(c *gin.Context, authD *AccessDetails) (string, error)

CompareData : compare extracted token data with data stored in redis

func ExtractToken

func ExtractToken(r *http.Request) string

ExtractToken ...

func GenToken

func GenToken(id primitive.ObjectID) string

GenToken : generate jwt token (used in the request header)

func GetCollection

func GetCollection(dbname string, collection string) *mongo.Collection

GetCollection : get collection

func GetMongoDB

func GetMongoDB() *mongo.Client

GetMongoDB : get a connection to mongodb

func GetRedis

func GetRedis() *redis.Client

GetRedis ...

func InitMongo

func InitMongo(mongoURI string) error

InitMongo : initiate connection to mongodb

func InitRedis

func InitRedis() error

InitRedis : initialize connection to redis

func RandString

func RandString(n int) string

RandString : generate random string

func ValidateToken

func ValidateToken(r *http.Request) error

ValidateToken ...

func VerifyToken

func VerifyToken(r *http.Request) (*jwt.Token, error)

VerifyToken ...

Types

type AccessDetails

type AccessDetails struct {
	AccessUUID string
	UserID     string
}

AccessDetails ...

func ExtractTokenMetadata

func ExtractTokenMetadata(r *http.Request) (*AccessDetails, error)

ExtractTokenMetadata ...

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	AccessUUID   string
	RefreshUUID  string
	AtExpires    int64
	RtExpires    int64
}

TokenDetails ...

func CreateToken

func CreateToken(userid primitive.ObjectID) (*TokenDetails, error)

CreateToken ...

Jump to

Keyboard shortcuts

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