{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "Framework :: Flask", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Flask-Access [![CircleCI](https://circleci.com/gh/barischrooneyj/flask-access.svg?style=svg)](https://circleci.com/gh/barischrooneyj/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) -> 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\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "flask-access", "package_url": "https://pypi.org/project/flask-access/", "platform": "", "project_url": "https://pypi.org/project/flask-access/", "project_urls": null, "release_url": "https://pypi.org/project/flask-access/0.1.2.1/", "requires_dist": null, "requires_python": ">=3", "summary": "A Flask extension which limits access to views.", "version": "0.1.2.1" }, "last_serial": 5105827, "releases": { "0.1": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "e5f6f8e504c1b9cc63ea7b4142d827cb", "sha256": "c71e28445525d51217b98ca40376bd059958f14b0864c0e9197d3baa3bbb3fe9" }, "downloads": -1, "filename": "flask_access-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e5f6f8e504c1b9cc63ea7b4142d827cb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 4938, "upload_time": "2019-04-05T21:11:15", "url": "https://files.pythonhosted.org/packages/73/96/820721efb98bdc5cc74457a25d9b9939cfeebaac44e8b19fd98c66da85c0/flask_access-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d5151618956acba86afdd1966d6c2c04", "sha256": "16319f2f0da749cc3566be0b6706cc4d0c43d2d602ca542f12b69e5d33179f65" }, "downloads": -1, "filename": "flask-access-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d5151618956acba86afdd1966d6c2c04", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 3434, "upload_time": "2019-04-05T21:11:17", "url": "https://files.pythonhosted.org/packages/5a/38/8a1d4dc9d065a699156db3eea41a753563bd80a7d6793055d07b117f61d9/flask-access-0.1.1.tar.gz" } ], "0.1.1.1": [ { "comment_text": "", "digests": { "md5": "a8b35d06d7fb97b2bf806fac9991aeb7", "sha256": "2a68c865a122bc09f2c1ab51d05ca04c2f9557e2983f7daefe6b14a7097c20cf" }, "downloads": -1, "filename": "flask_access-0.1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a8b35d06d7fb97b2bf806fac9991aeb7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 4758, "upload_time": "2019-04-05T21:45:20", "url": "https://files.pythonhosted.org/packages/d2/c2/da7d0619ef652af11c99c0ba827d9b4f13806645fddd52b96daf1dfe4a77/flask_access-0.1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "acab5200c3b11be3b2f78b9a14d3a6e1", "sha256": "1fb6a7c876498fd5a6b052b1bf765e0d4c0279fab72c7c5a363c9f0bdeb22815" }, "downloads": -1, "filename": "flask-access-0.1.1.1.tar.gz", "has_sig": false, "md5_digest": "acab5200c3b11be3b2f78b9a14d3a6e1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 3398, "upload_time": "2019-04-05T21:45:21", "url": "https://files.pythonhosted.org/packages/1b/9f/825a1de36f512cb8a20433b39f60ad208e0d6a83a39be904e91019cfade3/flask-access-0.1.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "85a2e1e3befe6e7bed305fee2be3fafa", "sha256": "35c189a270a1762de26f33191e292fbdb8e5e8659ca7b1e1ca435e6c273677f6" }, "downloads": -1, "filename": "flask_access-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "85a2e1e3befe6e7bed305fee2be3fafa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 4740, "upload_time": "2019-04-05T21:40:25", "url": "https://files.pythonhosted.org/packages/c7/6c/461ea2c3d9f2ec146c32edb0e3cb17651bc2e2ccc9828d9bcb0a96d632fc/flask_access-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "30c646bc9650bc451a4ee1674b69a032", "sha256": "6081187ea6ee0da55ddeb57cd40c1a060da3594dfcba5352d3bcda5ed5b76e6e" }, "downloads": -1, "filename": "flask-access-0.1.2.tar.gz", "has_sig": false, "md5_digest": "30c646bc9650bc451a4ee1674b69a032", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 3393, "upload_time": "2019-04-05T21:40:26", "url": "https://files.pythonhosted.org/packages/b0/7d/abeed7b82e5db8be2fe096fa069a1befbc23fe6466f58dce0be471fe4063/flask-access-0.1.2.tar.gz" } ], "0.1.2.1": [ { "comment_text": "", "digests": { "md5": "4963d4dc81905cc1cca22e8aac822209", "sha256": "3bd82d9e1b32b80b6a1c1f7ca2cb32682aac8a1b4f93bf67291a92b280b0ce6b" }, "downloads": -1, "filename": "flask_access-0.1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4963d4dc81905cc1cca22e8aac822209", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 4757, "upload_time": "2019-04-05T21:47:59", "url": "https://files.pythonhosted.org/packages/01/ea/34cba27dac32503d0292db5e2b6a080255a102feb21ddbd9527071414cf8/flask_access-0.1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "258a7713ec11ea39a030fe18e7e4b1fe", "sha256": "b32ed7b1ed73f9313bef61f645f8a7c06448390ece65fa0137e4aeff3b7e6c85" }, "downloads": -1, "filename": "flask-access-0.1.2.1.tar.gz", "has_sig": false, "md5_digest": "258a7713ec11ea39a030fe18e7e4b1fe", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 3400, "upload_time": "2019-04-05T21:48:00", "url": "https://files.pythonhosted.org/packages/a9/83/ea6cb8d6e499da4c0e72f419029353e1d8cc84e53e445f0549ab6393b9ec/flask-access-0.1.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4963d4dc81905cc1cca22e8aac822209", "sha256": "3bd82d9e1b32b80b6a1c1f7ca2cb32682aac8a1b4f93bf67291a92b280b0ce6b" }, "downloads": -1, "filename": "flask_access-0.1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4963d4dc81905cc1cca22e8aac822209", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 4757, "upload_time": "2019-04-05T21:47:59", "url": "https://files.pythonhosted.org/packages/01/ea/34cba27dac32503d0292db5e2b6a080255a102feb21ddbd9527071414cf8/flask_access-0.1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "258a7713ec11ea39a030fe18e7e4b1fe", "sha256": "b32ed7b1ed73f9313bef61f645f8a7c06448390ece65fa0137e4aeff3b7e6c85" }, "downloads": -1, "filename": "flask-access-0.1.2.1.tar.gz", "has_sig": false, "md5_digest": "258a7713ec11ea39a030fe18e7e4b1fe", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 3400, "upload_time": "2019-04-05T21:48:00", "url": "https://files.pythonhosted.org/packages/a9/83/ea6cb8d6e499da4c0e72f419029353e1d8cc84e53e445f0549ab6393b9ec/flask-access-0.1.2.1.tar.gz" } ] }