{"id":13705502,"url":"https://github.com/pyx/sanic-auth","last_synced_at":"2025-04-29T20:30:39.185Z","repository":{"id":55618789,"uuid":"91537579","full_name":"pyx/sanic-auth","owner":"pyx","description":"Sanic-Auth - Simple Authentication for Sanic","archived":false,"fork":false,"pushed_at":"2023-10-20T22:53:31.000Z","size":40,"stargazers_count":54,"open_issues_count":5,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T05:24:14.872Z","etag":null,"topics":["authentication","sanic"],"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/pyx.png","metadata":{"files":{"readme":"README.rst","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":"AUTHORS"}},"created_at":"2017-05-17T05:38:06.000Z","updated_at":"2024-06-10T02:57:22.000Z","dependencies_parsed_at":"2024-01-14T21:09:01.055Z","dependency_job_id":"2a9b34c7-17b9-4624-b206-d376312b1472","html_url":"https://github.com/pyx/sanic-auth","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyx%2Fsanic-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyx%2Fsanic-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyx%2Fsanic-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyx%2Fsanic-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyx","download_url":"https://codeload.github.com/pyx/sanic-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251578251,"owners_count":21611999,"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":["authentication","sanic"],"created_at":"2024-08-02T22:00:42.600Z","updated_at":"2025-04-29T20:30:38.902Z","avatar_url":"https://github.com/pyx.png","language":"Python","funding_links":[],"categories":["Extensions"],"sub_categories":["Authentication"],"readme":"============================================\nSanic-Auth - Simple Authentication for Sanic\n============================================\n\nSanic-Auth implements a minimal backend agnostic session-based user\nauthentication mechanism for `Sanic`_.\n\n\n.. _Sanic: https://github.com/channelcat/sanic\n\n\nQuick Start\n===========\n\n\nInstallation\n------------\n\n.. code-block:: sh\n\n  pip install --upgrade Sanic-Auth\n\n\nHow to use it\n-------------\n\n.. code-block:: python\n\n  from sanic_auth import Auth\n  from sanic import Sanic, response\n\n\n  app = Sanic(__name__)\n  app.config.AUTH_LOGIN_ENDPOINT = 'login'\n\n\n  @app.middleware('request')\n  async def add_session_to_request(request):\n      # setup session\n\n  auth = Auth(app)\n\n  @app.route('/login', methods=['GET', 'POST'])\n  async def login(request):\n      message = ''\n      if request.method == 'POST':\n          username = request.form.get('username')\n          password = request.form.get('password')\n          # fetch user from database\n          user = some_datastore.get(name=username)\n          if user and user.check_password(password):\n              auth.login_user(request, user)\n              return response.redirect('/profile')\n      return response.html(HTML_LOGIN_FORM)\n\n\n  @app.route('/logout')\n  @auth.login_required\n  async def logout(request):\n      auth.logout_user(request)\n      return response.redirect('/login')\n\n\n  @app.route('/profile')\n  @auth.login_required(user_keyword='user')\n  async def profile(request, user):\n      return response.json({'user': user})\n\n\nFor more details, please see documentation.\n\n\nLicense\n=======\n\nBSD New, see LICENSE for details.\n\n\nLinks\n=====\n\n- `Documentation \u003chttp://sanic-auth.readthedocs.org/\u003e`_\n\n- `Issue Tracker \u003chttps://github.com/pyx/sanic-auth/issues/\u003e`_\n\n- `Source Package @ PyPI \u003chttps://pypi.python.org/pypi/sanic-auth/\u003e`_\n\n- `Git Repository @ Github\n  \u003chttps://github.com/pyx/sanic-auth/\u003e`_\n\n- `Git Repository @ Gitlab\n  \u003chttps://gitlab.com/pyx/sanic-auth/\u003e`_\n\n- `Development Version\n  \u003chttp://github.com/pyx/sanic-auth/zipball/master#egg=sanic-auth-dev\u003e`_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyx%2Fsanic-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyx%2Fsanic-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyx%2Fsanic-auth/lists"}