utils

package
v0.0.0-...-eddbae0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(exp int64, secret []byte, userId int32, authLevel AuthLevel) (string, error)

func IsAuthorized

func IsAuthorized(ctx context.Context, requiredLevel AuthLevel) (bool, error)

IsAuthorized is a auth helper for resolvers

func ParseJWT

func ParseJWT(key *[]byte, msg string) (*jwt.Token, error)

func SetAuth

func SetAuth(ctx context.Context, authToken string, jwtSecret *[]byte) context.Context

Types

type AuthLevel

type AuthLevel int
const (
	AuthAnonymous AuthLevel = iota
	AuthUser
	AuthAdmin
)

func (AuthLevel) Authorized

func (a AuthLevel) Authorized(level AuthLevel) bool

Jump to

Keyboard shortcuts

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