func CheckPermission(e *casbin.Enforcer, r *http.Request) bool {
	user := GetUserName(r)
	method := r.Method
	path := r.URL.Path
	return e.Enforce(user, path, method)
}
CheckPermission checks the user/method/path combination from the request.
Returns true (permission granted) or false (permission forbidden)
package authz
import (
	"net/http"
	"github.com/casbin/casbin"
	"github.com/urfave/negroni"
)
func Authorizer(e *casbin.Enforcer) negroni.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
		if !CheckPermission(e, r) {
			http.Error(w, http.StatusText(403), 403)
		} else {
			next(w, r)
		}
	}
}
func GetUserName(r *http.Request) string {
	username, _, _ := r.BasicAuth()
	return username
}