utils

package
v0.0.0-...-8f801f6 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPass

func CheckPass(enteredPassword string, savedPassword []byte) bool

CheckPass will check if a user's saved password and a given hashed password are the same

func ExtractToken

func ExtractToken(r *http.Request) string

ExtractToken Given a request which contains "Authorization" field, extracts the token

func HashPassword

func HashPassword(password string) []byte

HashPassword will hash a given string into a unreadable byte array

func RefreshTokenIsValid

func RefreshTokenIsValid(refreshToken string) (string, error)

RefreshTokenIsValid Just refresh tokens given a valid refresh token

func TokenIsValid

func TokenIsValid(r *http.Request) error

TokenIsValid Checks if token in request header is valid

func VerifyToken

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

VerifyToken Given a token, checks if it's valid

Types

type AccessDetails

type AccessDetails struct {
	AccessUUID string
	UserID     string
}

AccessDetails Represents an access with its details

func ExtractTokenMetadata

func ExtractTokenMetadata(r *http.Request) (*AccessDetails, error)

ExtractTokenMetadata Given a token string, extracts the metadata contained in it

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	AccessUUID   string
	RefreshUUID  string
	AtExpires    int64
	RtExpires    int64
}

TokenDetails Represents a token

func GenerateToken

func GenerateToken(userID string) (*TokenDetails, error)

GenerateToken Given an user id as parameter, returns a JWT token

Jump to

Keyboard shortcuts

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