token

package
v0.0.0-...-a88db0e Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetToken

func SetToken(w http.ResponseWriter, r *http.Request, db *mgo.Session, userID string, userGroups []string, redirectURL string, JWTAccessSecret string, JWTRefreshSecret string) *handler.AppError

SetToken sets both an access token and refresh token to the cookies An access token is base64 URL encoded A refresh token is encoded in a gorilla session After this it redirects to the given redirect url (both relative and absolute)

Types

type Claims

type Claims struct {
	ProgramVersion string   `json:"programVersion"`
	UserAgent      string   `json:"userAgent"`
	UserGroups     []string `json:"userGroups"`
	jwt.StandardClaims
}

Claims defines what will be stored in a JWT access token

type RefreshClaims

type RefreshClaims struct {
	UserID        string   `json:"userId"`
	UserGroups    []string `bson:"userGroups"`
	Version       string   `json:"version"`
	RemoteAddress string   `json:"remoteAddress"`
	UserAgent     string   `json:"userAgent"`
	jwt.StandardClaims
}

RefreshClaims defines what will be in the JWT refresh token

type RefreshToken

type RefreshToken struct {
	CreatedAt          time.Time `bson:"createdAt"`
	UserID             string    `bson:"userId"`
	UserGroups         []string  `bson:"userGroups"`
	RefreshTokenString string    `bson:"refreshTokenString"`
	Expire             time.Time `bson:"expirationTime"`
	Valid              bool      `bson:"valid"`
}

RefreshToken defines what will be stored in the database of the RefreshToken

Jump to

Keyboard shortcuts

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