middleware

package
v0.0.0-...-054b70b Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CasbinService

type CasbinService struct {
	TokenService *TokenService    `inject:""`
	Enforcer     *casbin.Enforcer `inject:""`
	UserRepo     *repo.UserRepo   `inject:""`
	TokenRepo    *repo.TokenRepo  `inject:""`
}

func NewCasbinService

func NewCasbinService() *CasbinService

func (*CasbinService) Check

func (c *CasbinService) Check(r *http.Request, userId string) (bool, error)

Check checks the username, request's method and path and returns true if permission grandted otherwise false.

func (*CasbinService) Serve

func (m *CasbinService) Serve(ctx iris.Context)

type JwtService

type JwtService struct {
	Config middlewareUtils.Config
}

JwtService the middleware for JSON Web tokens authentication method

func NewJwtService

func NewJwtService() *JwtService

New constructs a new Secure instance with supplied options.

func (*JwtService) CheckJWT

func (m *JwtService) CheckJWT(ctx iris.Context) error

CheckJWT the main functionality, checks for token

func (*JwtService) Serve

func (m *JwtService) Serve(ctx iris.Context)

Serve the middleware's action

type TokenService

type TokenService struct {
	Middleware *JwtService      `inject:""`
	Enforcer   *casbin.Enforcer `inject:""`
	UserRepo   *repo.UserRepo   `inject:""`
	TokenRepo  *repo.TokenRepo  `inject:""`
}

func NewTokenService

func NewTokenService() *TokenService

func (*TokenService) Get

func (m *TokenService) Get(ctx iris.Context) *jwt.Token

Get returns the user (&token) information for this client/request

func (*TokenService) GetCredentials

func (m *TokenService) GetCredentials(value *jwt.Token, ctx iris.Context) (
	credentials *domain.UserCredentials, err error)

func (*TokenService) Serve

func (m *TokenService) Serve(ctx iris.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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