{"id":15009683,"url":"https://github.com/pycasbin/tornado-authz","last_synced_at":"2026-03-07T06:02:09.670Z","repository":{"id":236190818,"uuid":"792108278","full_name":"pycasbin/tornado-authz","owner":"pycasbin","description":"Use Casbin in Tornado, Casbin is a powerful and efficient open-source access control library.","archived":false,"fork":false,"pushed_at":"2024-05-11T16:13:45.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-30T04:35:18.281Z","etag":null,"topics":["abac","acl","auth","authorization","casbin","middleware","py","pycasbin","python","rbac","tornado"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/pycasbin","language":"Python","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/pycasbin.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-26T01:55:07.000Z","updated_at":"2025-03-24T17:19:12.000Z","dependencies_parsed_at":"2024-09-28T17:01:14.086Z","dependency_job_id":"adae6413-8474-46f0-ba09-730a30450165","html_url":"https://github.com/pycasbin/tornado-authz","commit_stats":null,"previous_names":["pycasbin/tornado-authz"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pycasbin/tornado-authz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Ftornado-authz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Ftornado-authz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Ftornado-authz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Ftornado-authz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pycasbin","download_url":"https://codeload.github.com/pycasbin/tornado-authz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pycasbin%2Ftornado-authz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30208801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T05:23:27.321Z","status":"ssl_error","status_checked_at":"2026-03-07T05:00:17.256Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","acl","auth","authorization","casbin","middleware","py","pycasbin","python","rbac","tornado"],"created_at":"2024-09-24T19:27:29.655Z","updated_at":"2026-03-07T06:02:09.644Z","avatar_url":"https://github.com/pycasbin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tornado-authz\n\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord\u0026label=discord\u0026color=5865F2)](https://discord.gg/S5UjpzGZjN)\n\n## Installation\n\nClone this repo\n\n```bash\ngit clone https://github.com/pycasbin/tornado-authz\n```\n\n## Simple Example\n\n```python\nimport asyncio\nimport tornado\nfrom casbin import Enforcer\n\nfrom tornado_authz import CasbinMiddleware\n\n\n# Create a CasbinMiddleware instance with the enforcer\nenforcer = Enforcer(\"../examples/authz_model.conf\", \"../examples/authz_policy.csv\")\nmiddleware = CasbinMiddleware(enforcer)\n\n\nclass BaseHandler(tornado.web.RequestHandler):\n    def get_current_user(self):\n        user = None\n        if self.get_secure_cookie(\"user\"):\n            user = self.get_secure_cookie(\"user\").decode('utf-8')\n        return user\n\n    def prepare(self):\n        # Check the permission for the current request\n        middleware(self)\n\n\nclass MainHandler(BaseHandler):\n    def get(self):\n        self.write(\"Main Page\")\n\n\nclass LoginHandler(BaseHandler):\n    def get(self):\n        self.write('\u003chtml\u003e\u003cbody\u003e\u003cform action=\"/login\" method=\"post\"\u003e'\n                   'Name: \u003cinput type=\"text\" name=\"name\"\u003e'\n                   '\u003cinput type=\"submit\" value=\"Sign in\"\u003e'\n                   '\u003c/form\u003e\u003c/body\u003e\u003c/html\u003e')\n\n    def post(self):\n        self.set_secure_cookie(\"user\", self.get_argument(\"name\"))\n        self.redirect(\"/dataset1/\")\n\n\nclass DatasetHandler(BaseHandler):\n    def get(self):\n        self.write(\"You must be alice to see this.\")\n\n\ndef make_app():\n    return tornado.web.Application([\n        (r\"/\", MainHandler),\n        (r\"/login\", LoginHandler),\n        (r\"/dataset1/.*\", DatasetHandler),\n    ], cookie_secret=\"__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__\")\n\n\nasync def main():\n    app = make_app()\n    app.listen(8888)\n    await asyncio.Event().wait()\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n\n```\n\n## Documentation\n\nThe authorization determines a request based on ``{subject, object, action}``, which means what ``subject`` can perform\nwhat ``action`` on what ``object``. In this plugin, the meanings are:\n\n1. ``subject``: the logged-in username\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\nFor how to write authorization policy and other details, please refer to [the Casbin's documentation](https://casbin.org).\n\n## Getting Help\n\n- [Casbin](https://casbin.org)\n\n## License\n\nThis project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpycasbin%2Ftornado-authz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpycasbin%2Ftornado-authz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpycasbin%2Ftornado-authz/lists"}