middleware

package
v0.0.0-...-3c0f6d4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminMiddleware

func AdminMiddleware(next echo.HandlerFunc) echo.HandlerFunc

Admin role

func AuthJWTMiddleware

func AuthJWTMiddleware(authService service.AuthService, config *config.Config) echo.MiddlewareFunc

JWT way of auth using cookie or Authorization header

Types

type AuthService

type AuthService interface {
	Register(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)
	Update(ctx context.Context, user *entity.User) (*entity.User, error)
	Delete(ctx context.Context, userID uuid.UUID) error
	GetUserByID(ctx context.Context, userID uuid.UUID) (*entity.User, error)
	FindUsersByName(ctx context.Context, name string, pq *utils.PaginationQuery) (*entity.UsersList, error)
	GetUsers(ctx context.Context, pq *utils.PaginationQuery) (*entity.UsersList, error)
	Login(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)
}

Auth Service interface

type MiddlewareManager

type MiddlewareManager struct {
	// contains filtered or unexported fields
}

Middleware manager

func NewMiddlewareManager

func NewMiddlewareManager(sessionService SessionService, authService AuthService, config *config.Config, origins []string, logger logger.Logger) *MiddlewareManager

Middleware manager constructor

func (*MiddlewareManager) AuthSessionMiddleware

func (mw *MiddlewareManager) AuthSessionMiddleware(next echo.HandlerFunc) echo.HandlerFunc

Auth sessions middleware using redis

func (*MiddlewareManager) CSRF

CSRF middleware

func (*MiddlewareManager) CheckAuth

func (mw *MiddlewareManager) CheckAuth(next echo.HandlerFunc) echo.HandlerFunc

Check auth middleware

func (*MiddlewareManager) OwnerOrAdminMiddleware

func (mw *MiddlewareManager) OwnerOrAdminMiddleware() echo.MiddlewareFunc

func (*MiddlewareManager) RoleBasedAuthMiddleware

func (mw *MiddlewareManager) RoleBasedAuthMiddleware(roles []string) echo.MiddlewareFunc

Role based auth middleware, using ctx user

type SessionService

type SessionService interface {
	CreateSession(ctx context.Context, session *entity.Session, expire int) (string, error)
	GetSessionByID(ctx context.Context, sessionID string) (*entity.Session, error)
	DeleteSessionByID(ctx context.Context, sessionID string) error
}

Session service interface

Jump to

Keyboard shortcuts

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