utils

package
v1.7.1-0...-092312a Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClaimKeys = OceanBrigdeClaims{
	Email:  "oceanbridge_email",
	Scopes: "oceanbridge_scopes",
}

ClaimKeys defines the claim key constants

View Source
var DevMode bool = strings.ToLower(os.Getenv("CARGOWISE_OCEANBRIDGE_REST_WRAPPER_DEV_MODE")) == "true"

DevMode defines if the application is run on dev mode

Functions

func DecodeToken

func DecodeToken(token string, signingKey string) (*jwt.Token, *jwt.MapClaims, error)

DecodeToken to get the claims/values of a JWT

func GenerateToken

func GenerateToken(claims map[string]interface{}, expireIn *time.Duration, signingKey string) (*string, error)

GenerateToken a JWT token

func GetValidSession

func GetValidSession(sessions *[]models.AuthSession, signingKey string) (*models.AuthSession, []string)

GetValidSession gets a valid session from the list, also returns the list of invalid sessions for clean up purpose

func ParseAccessToken

func ParseAccessToken(r *http.Request, w *http.ResponseWriter) (*persistent.User, *jwt.MapClaims)

ParseAccessToken will try to parse the JWT, from the Authorization header then return the user instance as well as the decoded claims map

func SecureCompare

func SecureCompare(given string, actual string) bool

SecureCompare performs a constant time compare of two strings to limit timing attacks. https://github.com/go-macaron/auth/blob/884c0e6c9b92ceebf12101d6cf1417fe0f61bcac/util.go

func SetCors

func SetCors(w *http.ResponseWriter)

SetCors settings the CORS headers

Types

type OceanBrigdeClaims

type OceanBrigdeClaims struct {
	Email  string
	Scopes string
}

OceanBrigdeClaims struct

Jump to

Keyboard shortcuts

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