Read the Caddyfile for config file path.
Caddy-authz is an authorization middleware for Caddy, it's based on https://github.com/casbin/casbin.
go get github.com/casbin/caddy-authz
package main import ( "net/http" "github.com/casbin/caddy-authz" "github.com/casbin/casbin" "github.com/mholt/caddy/caddyhttp/httpserver" ) func main() { // load the casbin model and policy from files, database is also supported. e := casbin.NewEnforcer("authz_model.conf", "authz_policy.csv") // define your handler, this is just an example to return HTTP 200 for any requests. // the access that is denied by authz will return HTTP 403 error. handler := authz.Authorizer{ Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { return http.StatusOK, nil }), Enforcer: e, } }
This project is under Apache 2.0 License. See the LICENSE file for the full license text.