caddy-authz

Caddy-authz is a middleware for Caddy that blocks or allows requests based on access control policies.

Github星跟蹤圖

Caddy-authz Build Status Coverage Status GoDoc

Caddy-authz is an authorization middleware for Caddy, it's based on https://github.com/casbin/casbin.

Installation

go get github.com/casbin/caddy-authz

Caddyfile syntax

http://localhost:80 {
    authz "/folder/to/caddy_binary/authz_model.conf" "/folder/to/caddy_binary/authz_policy.csv"
    ...
}

The authz directive specifies the path to Casbin model file (.conf) and Casbin policy file (.csv). The Casbin model file describes access control models like ACL, RBAC, ABAC, etc. The Casbin policy file describes the authorization policy rules. For how to write these files, please refer to: https://github.com/casbin/casbin#get-started

A working example

  1. cd into the folder of caddy binary.

  2. Put your Casbin model file authz_model.conf and Casbin policy file authz_policy.csv into this folder.

  3. Add authz directive to your Caddyfile like:

http://localhost:80 {
    authz "authz_model.conf" "authz_policy.csv"
    root "/my-website.net"
}
  1. Run caddy and enjoy.

Note: This plugin only supports HTTP basic authentication to get the logged-in user name, if you use other kinds of authentication like OAuth, LDAP, etc, you may need to customize this plugin.

How to control the access

The authorization determines a request based on {subject, object, action}, which means what subject can perform what action on what object. In this plugin, the meanings are:

  1. subject: the logged-on user name
  2. object: the URL path for the web resource like "dataset1/item1"
  3. action: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like "read-file", "write-blog"

For how to write authorization policy and other details, please refer to the Casbin's documentation.

Getting Help

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.

主要指標

概覽
名稱與所有者casbin/caddy-authz
主編程語言Go
編程語言Go (語言數: 1)
平台
許可證Apache License 2.0
所有者活动
創建於2017-05-27 05:31:36
推送於2023-08-06 14:09:08
最后一次提交2021-01-30 20:51:55
發布數4
最新版本名稱v2.0.0 (發布於 )
第一版名稱v1.0.0 (發布於 )
用户参与
星數243
關注者數3
派生數16
提交數29
已啟用問題?
問題數6
打開的問題數0
拉請求數7
打開的拉請求數0
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?