{"id":18474428,"url":"https://github.com/pgjones/quart-auth","last_synced_at":"2025-04-05T01:05:02.455Z","repository":{"id":38024885,"uuid":"478714268","full_name":"pgjones/quart-auth","owner":"pgjones","description":"Quart-Auth is an extension for Quart to provide for secure cookie authentication (session management).","archived":false,"fork":false,"pushed_at":"2024-12-26T21:46:14.000Z","size":114,"stargazers_count":49,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T00:11:57.644Z","etag":null,"topics":["quart"],"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/pgjones.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","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":"2022-04-06T20:19:45.000Z","updated_at":"2025-03-16T15:47:59.000Z","dependencies_parsed_at":"2024-05-18T13:43:34.562Z","dependency_job_id":"2e24b827-8d4f-4ced-8b54-6273124bed23","html_url":"https://github.com/pgjones/quart-auth","commit_stats":{"total_commits":69,"total_committers":7,"mean_commits":9.857142857142858,"dds":"0.10144927536231885","last_synced_commit":"eca73311ad3af1185d87ab9c09cc43a0e2bf8fc9"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgjones%2Fquart-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgjones%2Fquart-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgjones%2Fquart-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgjones%2Fquart-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgjones","download_url":"https://codeload.github.com/pgjones/quart-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247271520,"owners_count":20911587,"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":["quart"],"created_at":"2024-11-06T10:29:26.162Z","updated_at":"2025-04-05T01:05:02.421Z","avatar_url":"https://github.com/pgjones.png","language":"Python","readme":"Quart-Auth\n==========\n\n|Build Status| |docs| |pypi| |python| |license|\n\nQuart-Auth is an extension for `Quart\n\u003chttps://gitlab.com/pgjones/quart\u003e`_ to provide for secure cookie\nauthentication (session management). It allows for a session to be\nlogged in, authenticated and logged out.\n\nUsage\n-----\n\nTo use Quart-Auth with a Quart app you have to create an QuartAuth and\ninitialise it with the application,\n\n.. code-block:: python\n\n    app = Quart(__name__)\n    QuartAuth(app)\n\nor via the factory pattern,\n\n.. code-block:: python\n\n    auth_manager = QuartAuth()\n\n    def create_app():\n        app = Quart(__name__)\n        auth_manager.init_app(app)\n        return app\n\nIn addition you will need to configure Quart-Auth, which defaults to\nthe most secure. At a minimum you will need to set secret key,\n\n.. code-block:: python\n\n    app.secret_key = \"secret key\"  # Do not use this key\n\nwhich you can generate via,\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import secrets\n    \u003e\u003e\u003e secrets.token_urlsafe(16)\n\nYou may also need to disable secure cookies to use in development, see\nconfiguration below.\n\nWith QuartAuth initialised you can use the ``login_required``\nfunction to decorate routes that should only be accessed by\nauthenticated users,\n\n.. code-block:: python\n\n    from quart_auth import login_required\n\n    @app.route(\"/\")\n    @login_required\n    async def restricted_route():\n        ...\n\nIf no user is logged in, an ``Unauthorized`` exception is raised. To catch it,\ninstall an error handler,\n\n.. code-block:: python\n\n    @app.errorhandler(Unauthorized)\n    async def redirect_to_login(*_: Exception) -\u003e ResponseReturnValue:\n        return redirect(url_for(\"login\"))\n\nYou can also use the ``login_user``, and ``logout_user`` functions to\nstart and end sessions for a specific ``AuthenticatedUser`` instance,\n\n.. code-block:: python\n\n    from quart_auth import AuthUser, login_user, logout_user\n\n    @app.route(\"/login\")\n    async def login():\n        # Check Credentials here, e.g. username \u0026 password.\n        ...\n        # We'll assume the user has an identifying ID equal to 2\n        login_user(AuthUser(2))\n        ...\n\n    @app.route(\"/logout\")\n    async def logout():\n        logout_user()\n        ...\n\nThe user (authenticated or not) is available via the global\n``current_user`` including within templates,\n\n.. code-block:: python\n\n    from quart import render_template_string\n    from quart_auth import current_user\n\n    @app.route(\"/\")\n    async def user():\n        return await render_template_string(\"{{ current_user.is_authenticated }}\")\n\nContributing\n------------\n\nQuart-Auth is developed on `GitHub\n\u003chttps://github.com/pgjones/quart-auth\u003e`_. You are very welcome to\nopen `issues \u003chttps://github.com/pgjones/quart-auth/issues\u003e`_ or\npropose `pull requests\n\u003chttps://github.com/pgjones/quart-auth/pulls\u003e`_.\n\nTesting\n~~~~~~~\n\nThe best way to test Quart-Auth is with Tox,\n\n.. code-block:: console\n\n    $ pip install tox\n    $ tox\n\nthis will check the code style and run the tests.\n\nHelp\n----\n\nThe Quart-Auth `documentation\n\u003chttps://quart-auth.readthedocs.io\u003e`_ is the best places to\nstart, after that try searching `stack overflow\n\u003chttps://stackoverflow.com/questions/tagged/quart\u003e`_ or ask for help\n`on gitter \u003chttps://gitter.im/python-quart/lobby\u003e`_. If you still\ncan't find an answer please `open an issue\n\u003chttps://github.com/pgjones/quart-auth/issues\u003e`_.\n\n\n.. |Build Status| image:: https://github.com/pgjones/quart-auth/actions/workflows/ci.yml/badge.svg\n   :target: https://github.com/pgjones/quart-auth/commits/main\n\n.. |docs| image:: https://img.shields.io/badge/docs-passing-brightgreen.svg\n   :target: https://quart-auth.readthedocs.io\n\n.. |pypi| image:: https://img.shields.io/pypi/v/quart-auth.svg\n   :target: https://pypi.python.org/pypi/Quart-Auth/\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/quart-auth.svg\n   :target: https://pypi.python.org/pypi/Quart-Auth/\n\n.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg\n   :target: https://github.com/pgjones/quart-auth/blob/main/LICENSE\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgjones%2Fquart-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgjones%2Fquart-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgjones%2Fquart-auth/lists"}