{"id":29979684,"url":"https://github.com/jerbaroo/flask-access","last_synced_at":"2026-05-18T19:48:01.434Z","repository":{"id":132714761,"uuid":"71493602","full_name":"jerbaroo/flask-access","owner":"jerbaroo","description":"Easily protect access to Flask endpoints","archived":false,"fork":false,"pushed_at":"2020-12-18T20:39:27.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-04T15:56:49.328Z","etag":null,"topics":["access-control","flask","flask-extension"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jerbaroo.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,"zenodo":null}},"created_at":"2016-10-20T18:46:06.000Z","updated_at":"2020-12-18T20:39:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae1b6fb0-d690-40c1-82cc-f44179c6c673","html_url":"https://github.com/jerbaroo/flask-access","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jerbaroo/flask-access","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fflask-access","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fflask-access/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fflask-access/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fflask-access/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jerbaroo","download_url":"https://codeload.github.com/jerbaroo/flask-access/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerbaroo%2Fflask-access/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33189278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["access-control","flask","flask-extension"],"created_at":"2025-08-04T13:33:08.840Z","updated_at":"2026-05-18T19:48:01.428Z","avatar_url":"https://github.com/jerbaroo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask-Access [![CircleCI](https://circleci.com/gh/jerbaroo/flask-access.svg?style=svg)](https://circleci.com/gh/jerbaroo/flask-access)\n\nSimple protection of Flask endpoints.\n\nIntegrates well with [Flask-Login](https://flask-login.readthedocs.io/en/latest/).\n\n## Protect endpoints\n\nHere the endpoint `\"/secret-code\"` requires a user to have `\"admin\"` rights:\n\n``` Python\n@app.route(\"/secret-code\")\n@flask_access.require(\"admin\")\ndef secret_code():\n    return \"1234\"\n```\n\nYou could have other requirements:\n\n``` Python\n@flask_access.require(\"boss\", 7, funny=True, bald=None)\n```\n\n## Register a user loader\n\nFlas-Access needs to associate the current request with a user that\nhas permission or not. Flask-Access will look for the current user\nin `app.config[flask_access.CURRENT_USER]`, here you can assign a\nfunction that returns the current user.\n\n``` Python\napp.config[flask_access.CURRENT_USER] = my_current_user_func\n```\n\nThe type of the returned user can be whatever you are using in your\napplication to model users already, the only condition is that the user\nclass implements a method `has_access`. If the user has no account return\n`True` to allow access. Anything other than `True` or an instance of a\nclass implementing `has_access` will have access denied.\n\nIf you are also using Flask-Login you can simply apply the assignment\nbelow :clap:\n\n``` Python\napp.config[flask_access.CURRENT_USER] = flask_login.current_user\n\n```\n\n## User access logic\n\nIn short, implement `has_access(self, rights) -\u003e bool` on your user class.\n\nWhen a user attempts to access an endpoint, Flask-Access will load the current\nuser object `user` and run `user.has_access(rights)`, the `rights` that get\npassed in are the `\"boss\", 7, funny=True, bald=None` from above.\n\nIf a user doesn't have an `has_access` method, or the method doesn't return\n`True`, then access is denied :speak_no_evil:\n\n## Access denied handler\n\nThe default access denied handler calls `flask.abort(403)`\n\nTo set a custom access-denied handler:\n\n``` Python\napp.config[flask_access.ABORT_FN] = my_custom_abort_func\n```\n\n## Login required\n\nIf you are using `flask_login.current_user` as your user loader then\n`flask_access.require` implies `flask_login.login_required`, so no need to also\nspecify the latter.\n\nWhy? Well, if a user is not logged-in, `flask_login.current_user` will return a\n`flask_login.AnonymousUserMixin` which does not have `has_access` implemented,\nhence no access for the user.\n\n## Example\n\nAn [example](example/example.py) with a primitive login/out system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerbaroo%2Fflask-access","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerbaroo%2Fflask-access","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerbaroo%2Fflask-access/lists"}