tokenutils

package
v0.0.0-...-035dfa4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tokenutils provides utilities for JWTs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractRefreshToken

func ExtractRefreshToken(r *http.Request) string

func ExtractToken

func ExtractToken(r *http.Request) string

ExtractToken extracts an access token from request header

func ExtractUserId

func ExtractUserId(r *http.Request) uint

func RefreshAccessToken

func RefreshAccessToken(refreshToken *jwt.Token) (string, error)

func StillValid

func StillValid(token *jwt.Token) bool

func VerifyRefreshToken

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

VerifyRefreshToken verifies a refresh token is legit

func VerifyToken

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

VerifyToken verifies a token is legit

Types

type Claims

type Claims struct {
	UserId uint `json:"userid"` // User ID
	jwt.StandardClaims
}

Claims holds a UserId and standard claims

type Tokens

type Tokens struct {
	AccessToken  string
	RefreshToken string
}

Tokens holds an access token and a refresh token

func CreateToken

func CreateToken(userid uint) (*Tokens, error)

CreateToken takes an ID and generates a Tokens

Jump to

Keyboard shortcuts

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