middleware

package
v0.0.0-...-ca0d999 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuth

func NewAuth(enforce *casbin.Enforcer, jwtHandler token.JWTHandler, cfg config.Config) gin.HandlerFunc

Types

type JwtRoleAuth

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

func (*JwtRoleAuth) CheckPermission

func (a *JwtRoleAuth) CheckPermission(r *http.Request) (bool, error)

CheckPermission checks whether user is allowed to use certain endpoint

func (*JwtRoleAuth) GetRole

func (a *JwtRoleAuth) GetRole(r *http.Request) (string, error)

GetRole gets role from Authorization header if there is a token then it is parsed and in role got from role claim. If there is no token then role is unauthorized

func (*JwtRoleAuth) RequirePermission

func (a *JwtRoleAuth) RequirePermission(c *gin.Context)

RequirePermission aborts request with 403 status

func (*JwtRoleAuth) RequireRefresh

func (a *JwtRoleAuth) RequireRefresh(c *gin.Context)

RequireRefresh aborts request with 401 status

Jump to

Keyboard shortcuts

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