Skip to content

clevergo/authz

Repository files navigation

CleverGo Authorization Middleware

Build Status Coverage Status Go.Dev reference Go Report Card Release Downloads

Usage

import (
    "clevergo.tech/authz"
    "clevergo.tech/clevergo"
)
enforcer, _ := casbin.NewEnforcer("casbin_model.conf", "casbin_policy.csv")
userFunc := func(c *clevergo.Context) (id string, err error) {
    // returns the authenticated user ID.
    return
}
app := clevergo.New()
app.Use(authz.New(enforcer, userFunc))