{"id":19003803,"url":"https://github.com/kozea/flask-alcool","last_synced_at":"2026-03-06T11:32:30.045Z","repository":{"id":35668450,"uuid":"39943715","full_name":"Kozea/flask-alcool","owner":"Kozea","description":"ALCOOOL","archived":false,"fork":false,"pushed_at":"2024-11-08T08:07:30.000Z","size":10,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-24T16:23:47.364Z","etag":null,"topics":["acl","flask","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kozea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null},"funding":{"patreon":"kozea"}},"created_at":"2015-07-30T09:58:02.000Z","updated_at":"2024-11-08T08:07:34.000Z","dependencies_parsed_at":"2025-04-16T23:06:17.597Z","dependency_job_id":"b6625672-113e-46ec-8925-c1e32664fa7c","html_url":"https://github.com/Kozea/flask-alcool","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Kozea/flask-alcool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozea%2Fflask-alcool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozea%2Fflask-alcool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozea%2Fflask-alcool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozea%2Fflask-alcool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kozea","download_url":"https://codeload.github.com/Kozea/flask-alcool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozea%2Fflask-alcool/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266856204,"owners_count":23995653,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["acl","flask","python"],"created_at":"2024-11-08T18:20:24.642Z","updated_at":"2026-03-06T11:32:29.957Z","avatar_url":"https://github.com/Kozea.png","language":"Python","funding_links":["https://patreon.com/kozea"],"categories":[],"sub_categories":[],"readme":"# Flask-Alcool\n\nFlask-Alcool is a Flask extension to provide access control list like rights\nmanagement with decorators on routes. It also provide a jinja extension to\ndisplay only authorized links.\n\n## Install\n\n```\npip install Flask-Alcool\n```\n\n## Examples\n\n### Protect routes\n\n```python\nfrom flask.ext.alcool import alcool, allow_if\nfrom myproject import app\n\n\n@alcool\ndef drunk(**kwargs):\n    return kwargs.get('drunk', False)\n\n\n@alcool\ndef major(**kwargs):\n    value = kwargs.get('value', 0)\n    return True if value \u003e 18 else False\n\n\n@app.route('/test/\u003cint:age\u003e/\u003cbool:drunk\u003e')\n@allow_if(drunk | major)\ndef protected_route(value, drunk):\n    return \"route is major or drunk or both\"\n\n\n@app.route('/drive/\u003cbool:drunk\u003e')\n@allow_if(~drunk)\ndef drive(drunk):\n    return \"route is sober : drive safely\"\n\n\n@app.route('/welcome/\u003cbool:drunk\u003e/\u003cint:value\u003e')\n@allow_if(major \u0026 ~drunk)\ndef welcome_home(drunk, value):\n    return \"route is major and sober\"\n```\n\nIn real life you may want to place all alcool decorated function in a\nconditions.py file then do something like:\n\n```python\nimport conditions as Is\n\n@app.route('/test/\u003cint:age\u003e/\u003cbool:drunk\u003e')\n@allow_if(Is.drunk | Is.major)\ndef protected_route(value, drunk):\n    return \"route is major or drunk or both\"\n```\n\nAvailable alcool operators are:\n\n-   ``a \u0026 b`` → ``a and b``\n-   ``a | b`` → ``a or b``\n-   ``a ^ b`` → ``a xor b``\n-   ``~ a`` → ``not a``\n\n\n### Display links only for authorized routes\n\nUse this snippet to configure Jinja2:\n\n```python\nfrom flask.ext.alcool import Alcool\nalcool = Alcool(app)\n```\n\nThen, in templates you can use the new {% auth %} block:\n\n```html+jinja\n{% auth 'drive', {'drunk': false} %}\n  This text will be displayed\n{% endauth %}\n{% auth 'drive', {'drunk': true} %}\n  This text will not be displayed\n{% endauth %}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkozea%2Fflask-alcool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkozea%2Fflask-alcool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkozea%2Fflask-alcool/lists"}