common

package
v0.0.0-...-9494c46 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorize

func Authorize(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Middleware for validating JWT tokens

func DisplayAppError

func DisplayAppError(
	w http.ResponseWriter,
	handlerError error,
	message string,
	code int,
)

func GenerateJWT

func GenerateJWT(username, accessToken string) (string, error)

Generate JWT token

func GetJWTFromStore

func GetJWTFromStore(w http.ResponseWriter, r *http.Request) (token string)

func IsAuthenticated

func IsAuthenticated(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func NewContext

func NewContext(ctx context.Context, appClaims *AppClaims) context.Context

func StartUp

func StartUp()

func StoreJWT

func StoreJWT(w http.ResponseWriter, r *http.Request, token string)

Types

type AppClaims

type AppClaims struct {
	Id          int64  `json:"id"`
	Username    string `json:"username"`
	AccessToken string `json:"accessToken"`
	jwt.StandardClaims
}

AppClaims provides custom claim for JWT

func FromContext

func FromContext(ctx context.Context) (*AppClaims, bool)

Jump to

Keyboard shortcuts

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