authorization

package
v0.0.0-...-a21a18e Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteAuthFromRedis

func DeleteAuthFromRedis(givenUuid string, client *redis.Client, ctx context.Context) (int64, error)

delete key from redis

func FetchAuth

func FetchAuth(authD *AccessDetails, client *redis.Client, ctx context.Context) (uint64, error)

get user_id from access token

func GetAuthToken

func GetAuthToken(r *http.Request) string

get auth token from request object

func Refresh

func Refresh(refresh_token string, client *redis.Client, ctx context.Context) (map[string]string, error)

use refresh token to create new access token and refresh token

func TokenValid

func TokenValid(r string) error

func VerifyToken

func VerifyToken(authHeaderToken string) (*jwt.Token, error)

Types

type AccessDetails

type AccessDetails struct {
	AccessUuid string
	UserId     uint64
}

func ExtractTokenMetadata

func ExtractTokenMetadata(r string) (*AccessDetails, error)

type AuthHeaderKeyType

type AuthHeaderKeyType string
const AuthHeaderKey AuthHeaderKeyType = "Authorization"

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	AccessUuid   string
	RefreshUuid  string
	AtExpires    int64
	RtExpires    int64
}

func CreateToken

func CreateToken(userId int, client *redis.Client, ctx context.Context) (*TokenDetails, error)

generate tokens and store it to redis

type Tokens

type Tokens struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

Jump to

Keyboard shortcuts

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