middleware

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserContext

type UserContext struct {
	UserID int
}

UserContext represents the user context.

func GetUserContext

func GetUserContext(c echo.Context) (*UserContext, error)

GetUserContext gets the UserContext from the echo.Context. UserContext is created by the UserAuthentication middleware.

type UserMiddleware

type UserMiddleware struct {
	UserMiddlewareConfig
	UserMiddlewareDeps
}

UserMiddleware represents our user middleware.

func NewUserMiddleware

func NewUserMiddleware(cfg UserMiddlewareConfig, deps UserMiddlewareDeps) *UserMiddleware

NewUserMiddleware creates a new UserMiddleware.

func (*UserMiddleware) JWT

func (um *UserMiddleware) JWT() echo.MiddlewareFunc

JWT catches the access_token and verifies it. We also extract the UserContext information from the JWT and set it in the echo.Context.

type UserMiddlewareConfig

type UserMiddlewareConfig struct {
	GlobalTokenKey string
	CookieName     string
}

UserMiddlewareConfig represents the UserMiddleware config.

type UserMiddlewareDeps

type UserMiddlewareDeps struct {
	Logger    zerolog.Logger
	UserStore providers.UserStorer
}

UserMiddlewareDeps represents the UserMiddleware dependencies.

Jump to

Keyboard shortcuts

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