Skip to content

baa-middleware/authz

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

authz

baa middleware for authorization, it's based on https://github.com/casbin/casbin.

Use:

// Init 
	e := casbin.NewEnforcer("conf/rbac_model.conf", "conf/rbac_policy.csv")
	ini := authz.Config{
		ExcludeURL:    excludeURL,
		ExcludePrefix: excludePrefix,
		Extractor: func(c *baa.Context) (string, error) {
			customs, err := base.GetStandClaims(c)
			if err != nil {
				return "get user Info failure", err
			}
			return strconv.Itoa(customs.Auth.ID), nil
		},
	}
	b.Use(authz.Authorizer(e, ini))

Config:

ExcludeURL []string

skip authz for these url,for example login or register, /login,/register

ExcludePrefix []string

skip authz for these url prefix,for example login or register, /login,/register

Extractor

Custom methods to obtain user information, such as from JWT or session

About

baa middleware for authorization, it's based on https://github.com/casbin/casbin.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages