helpers

package
v0.0.0-...-4c323b9 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package helpers implements different helper functions used in other areas of the project helpers/environemnt_handler.go impelements handlers used to interact with env vars.

Index

Constants

This section is empty.

Variables

View Source
var TESTING_KEY string = ""

Functions

func Authentication

func Authentication() gin.HandlerFunc

func GenerateAllTokens

func GenerateAllTokens(email string, name string, isAdmin bool) (signedToken string, signedRefreshToken string, err error)

GenerateAllTokens generates both the detailed token and refresh token

func GetMongoURL

func GetMongoURL() string

GetMongoURL returns a Go string representing the URL for connecting to the MongoDB

func GetPort

func GetPort() string

GetPort returns a Go string that represents the PORT that will be set up for the API It's default value is 8000

func GetRefreshTokenDuration

func GetRefreshTokenDuration() int64

GetRefreshTokenDuration returns a go int64 that represents how long the refresh token should last

func GetSecretKey

func GetSecretKey() string

GetSecretKey returns a Go String that represents the SECRET_KEY used in JWT enconding

func GetTokenDuration

func GetTokenDuration() int64

GetTokenDuration returns a Go int64 that represents how long the original token should last

func UpdateAllTokens

func UpdateAllTokens(signedToken string, signedRefreshToken string, userId string)

UpdateAllTokens renews the user tokens when they login

Types

type SignedDetails

type SignedDetails struct {
	Email   string
	Name    string
	IsAdmin bool
	jwt.StandardClaims
}

A SignedDetails holds an email and it's encoded counterpart using JWT

func ValidateToken

func ValidateToken(signedToken string) (claims *SignedDetails, msg string)

ValidateToken validates the jwt token

Jump to

Keyboard shortcuts

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