{"id":19298238,"url":"https://github.com/casbin/caddy-authz","last_synced_at":"2025-04-07T06:10:25.980Z","repository":{"id":54769158,"uuid":"92573418","full_name":"casbin/caddy-authz","owner":"casbin","description":"Caddy-authz is a middleware for Caddy that blocks or allows requests based on access control policies.","archived":false,"fork":false,"pushed_at":"2023-08-06T14:09:08.000Z","size":131,"stargazers_count":240,"open_issues_count":0,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T22:37:41.902Z","etag":null,"topics":["abac","access-control","acl","authorization","caddy","casbin","filter","middleware","plugin","rbac"],"latest_commit_sha":null,"homepage":"https://caddyserver.com/docs/modules/http.handlers.authz","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casbin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"casbin"}},"created_at":"2017-05-27T05:31:36.000Z","updated_at":"2024-05-01T23:47:43.000Z","dependencies_parsed_at":"2022-08-14T02:11:05.028Z","dependency_job_id":null,"html_url":"https://github.com/casbin/caddy-authz","commit_stats":{"total_commits":24,"total_committers":6,"mean_commits":4.0,"dds":0.25,"last_synced_commit":"6cb348ced3f4fdebab3a600f4dd0ab9347b2b99f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcaddy-authz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcaddy-authz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcaddy-authz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fcaddy-authz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/caddy-authz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247458548,"owners_count":20942044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abac","access-control","acl","authorization","caddy","casbin","filter","middleware","plugin","rbac"],"created_at":"2024-11-09T23:07:22.218Z","updated_at":"2025-04-07T06:10:25.961Z","avatar_url":"https://github.com/casbin.png","language":"Go","funding_links":["https://github.com/sponsors/casbin"],"categories":[],"sub_categories":[],"readme":"Caddy-authz [![Build Status](https://travis-ci.com/casbin/caddy-authz.svg?branch=master)](https://travis-ci.com/casbin/caddy-authz) [![Coverage Status](https://coveralls.io/repos/github/casbin/caddy-authz/badge.svg?branch=master)](https://coveralls.io/github/casbin/caddy-authz?branch=master) [![GoDoc](https://godoc.org/github.com/casbin/caddy-authz?status.svg)](https://godoc.org/github.com/casbin/caddy-authz)\n======\n\nCaddy-authz is an authorization middleware for [Caddy](https://github.com/mholt/caddy), it's based on [https://github.com/casbin/casbin](https://github.com/casbin/casbin).\n\n## Installation\n\n    go get github.com/casbin/caddy-authz\n\n## Caddyfile syntax\n\n```\nlocalhost {\n    route { \n        authz \"/folder/to/caddy_binary/authz_model.conf\" \"/folder/to/caddy_binary/authz_policy.csv\"\n    }\n    respond \"Hello, world!\"\n    ...\n}\n```\n\nor\n\n```\n{\n    order authz before respond\n}\n\nlocalhost {\n\tauthz \"/folder/to/caddy_binary/authz_model.conf\" \"/folder/to/caddy_binary/authz_policy.csv\"\n\trespond \"Hello, world!\"\n    ...\n}\n```\n\nThe ``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\n\n## A working example\n\n1. ``cd`` into the folder of ``caddy`` binary.\n\n2. Put your Casbin model file [authz_model.conf](https://github.com/casbin/caddy-authz/blob/master/authz_model.conf) and Casbin policy file [authz_policy.csv](https://github.com/casbin/caddy-authz/blob/master/authz_policy.csv) into this folder.\n\n3. Add ``authz`` directive to your Caddyfile like:\n\n```\nlocalhost:666 {\n    route { \n        authz \"authz_model.conf\" \"authz_policy.csv\"\n    }\n    respond \"Hello, world!\"\n    ...\n}\n```\n\n4. Run ``caddy`` and enjoy.\n\nNote: 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.\n\n## How to control the access\n\nThe 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:\n\n1. ``subject``: the logged-on user name\n2. ``object``: the URL path for the web resource like \"dataset1/item1\"\n3. ``action``: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like \"read-file\", \"write-blog\"\n\n\nFor how to write authorization policy and other details, please refer to [the Casbin's documentation](https://github.com/casbin/casbin).\n\n## Getting Help\n\n- [Casbin](https://github.com/casbin/casbin)\n\n## License\n\nThis project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fcaddy-authz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fcaddy-authz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fcaddy-authz/lists"}