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
Click to show internal directories.
Click to hide internal directories.