security

package
v0.0.0-...-d308771 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashAndSalt

func HashAndSalt(pwd []byte) string

HashAndSalt hashes the plain password

func Login

func Login(c *gin.Context)

Login for JWT

func NewJwtAuthorizer

func NewJwtAuthorizer(e *casbin.Enforcer) gin.HandlerFunc

NewJwtAuthorizer returns the authorizer, uses a Casbin enforcer as input

Types

type JwtAuthorizer

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

JwtAuthorizer stores the casbin handler

func (*JwtAuthorizer) CheckPermission

func (a *JwtAuthorizer) CheckPermission(c *gin.Context) bool

CheckPermission checks the user/method/path combination from the request. Returns true (permission granted) or false (permission forbidden)

func (*JwtAuthorizer) GetUserName

func (a *JwtAuthorizer) GetUserName(r *http.Request) string

GetUserName gets the user name from the request. Currently, only HTTP basic authentication is supported

func (*JwtAuthorizer) RequirePermission

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

RequirePermission returns the 403 Forbidden to the client

Jump to

Keyboard shortcuts

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