{"id":19935991,"url":"https://github.com/imbolc/async_django_session","last_synced_at":"2025-10-14T07:35:07.419Z","repository":{"id":57412084,"uuid":"215235451","full_name":"imbolc/async_django_session","owner":"imbolc","description":"Django-compatible session for async frameworks","archived":false,"fork":false,"pushed_at":"2019-10-23T06:45:36.000Z","size":21,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-30T03:16:23.595Z","etag":null,"topics":["aiohttp","async","asyncio","django","fastapi","starlette"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imbolc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-15T07:31:48.000Z","updated_at":"2022-11-06T09:06:24.000Z","dependencies_parsed_at":"2022-09-09T17:31:15.355Z","dependency_job_id":null,"html_url":"https://github.com/imbolc/async_django_session","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imbolc/async_django_session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbolc%2Fasync_django_session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbolc%2Fasync_django_session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbolc%2Fasync_django_session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbolc%2Fasync_django_session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imbolc","download_url":"https://codeload.github.com/imbolc/async_django_session/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbolc%2Fasync_django_session/sbom","scorecard":{"id":485110,"data":{"date":"2025-08-11","repo":{"name":"github.com/imbolc/async_django_session","commit":"9553a9cc8c109b0258435a5a4ff19348485fea47"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"61 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2023-120 / GHSA-45c4-8wx5-qw6w","Warn: Project is vulnerable to: GHSA-5m98-qgg9-wh84","Warn: Project is vulnerable to: GHSA-7gpw-8wmc-pm8g","Warn: Project is vulnerable to: GHSA-8495-4g3g-x7pr","Warn: Project is vulnerable to: PYSEC-2024-26 / GHSA-8qpw-xqxj-h4r2","Warn: Project is vulnerable to: GHSA-9548-qrrj-x5pj","Warn: Project is vulnerable to: PYSEC-2023-246 / GHSA-gfw2-4jvh-wgfg","Warn: Project is vulnerable to: GHSA-pjjw-qhg8-p2p9","Warn: Project is vulnerable to: PYSEC-2023-250 / GHSA-q3qx-c6g2-7pw2","Warn: Project is vulnerable to: PYSEC-2023-251 / GHSA-qvrw-v9rv-5rjx","Warn: Project is vulnerable to: PYSEC-2021-76 / GHSA-v6wp-4m6f-gcjg","Warn: Project is vulnerable to: PYSEC-2023-247 / GHSA-xx9p-xxvh-7g8j","Warn: Project is vulnerable to: PYSEC-2020-24 / GHSA-2xpj-f5g2-8p7m","Warn: Project is vulnerable to: PYSEC-2014-5 / GHSA-296w-6qhq-gf92","Warn: Project is vulnerable to: PYSEC-2011-2 / GHSA-3jqw-crqj-w8qw","Warn: Project is vulnerable to: PYSEC-2012-3 / GHSA-59w8-4wm2-4xw8","Warn: Project is vulnerable to: PYSEC-2012-4 / GHSA-5h2q-4hrp-v9rr","Warn: Project is vulnerable to: PYSEC-2014-6 / GHSA-625g-gx8c-xcmg","Warn: Project is vulnerable to: PYSEC-2015-8 / GHSA-6565-fg86-6jcx","Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: PYSEC-2012-2 / GHSA-78vx-ggch-wghm","Warn: Project is vulnerable to: PYSEC-2015-9 / GHSA-7fq8-4pv5-5w5c","Warn: Project is vulnerable to: PYSEC-2015-4 / GHSA-7qfw-j7hp-v45g","Warn: Project is vulnerable to: PYSEC-2011-9 / GHSA-7wph-fc4w-wqp2","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: PYSEC-2014-2 / GHSA-89hj-xfx5-7q66","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2016-2 / GHSA-c8c8-9472-w52h","Warn: Project is vulnerable to: PYSEC-2016-3 / GHSA-crhm-qpjc-cm64","Warn: Project is vulnerable to: PYSEC-2014-4 / GHSA-f7cm-ccfp-3q4r","Warn: Project is vulnerable to: PYSEC-2016-16 / GHSA-fp6p-5xvw-m74f","Warn: Project is vulnerable to: PYSEC-2011-8 / GHSA-fwr5-q9rx-294f","Warn: Project is vulnerable to: PYSEC-2015-5 / GHSA-gv98-g628-m9x5","Warn: Project is vulnerable to: PYSEC-2015-20 / GHSA-h582-2pch-3xv3","Warn: Project is vulnerable to: PYSEC-2011-5 / GHSA-h95j-h2rv-qrg4","Warn: Project is vulnerable to: GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2015-6 / GHSA-jhjg-w2cp-5j44","Warn: Project is vulnerable to: PYSEC-2016-15 / GHSA-pw27-w7w4-9qc7","Warn: Project is vulnerable to: PYSEC-2015-10 / GHSA-q5qw-4364-5hhm","Warn: Project is vulnerable to: PYSEC-2011-4 / GHSA-rm2j-x595-q9cj","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2014-1 / GHSA-rvq6-mrpv-m6rm","Warn: Project is vulnerable to: PYSEC-2014-7 / GHSA-rw75-m7gp-92m3","Warn: Project is vulnerable to: PYSEC-2019-16 / GHSA-vfq6-hq5r-27r6","Warn: Project is vulnerable to: PYSEC-2014-3 / GHSA-wqjj-hx84-v449","Warn: Project is vulnerable to: PYSEC-2011-3 / GHSA-wxg3-mfph-qg9w","Warn: Project is vulnerable to: PYSEC-2011-1 / GHSA-x88j-93vc-wpmp","Warn: Project is vulnerable to: PYSEC-2007-1","Warn: Project is vulnerable to: PYSEC-2008-1","Warn: Project is vulnerable to: PYSEC-2008-2","Warn: Project is vulnerable to: PYSEC-2009-3","Warn: Project is vulnerable to: PYSEC-2015-11","Warn: Project is vulnerable to: PYSEC-2015-7","Warn: Project is vulnerable to: PYSEC-2016-18","Warn: Project is vulnerable to: PYSEC-2021-100 / GHSA-8h2j-cgx8-6xv7","Warn: Project is vulnerable to: PYSEC-2024-38","Warn: Project is vulnerable to: GHSA-2c2j-9gv5-cj73","Warn: Project is vulnerable to: PYSEC-2023-48 / GHSA-74m5-2c7w-9w3x","Warn: Project is vulnerable to: GHSA-f96h-pmfr-66vw","Warn: Project is vulnerable to: PYSEC-2020-150 / GHSA-33c7-2mpw-hg34","Warn: Project is vulnerable to: PYSEC-2020-151 / GHSA-f97h-2pfx-f59f"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T17:34:11.441Z","repository_id":57412084,"created_at":"2025-08-19T17:34:11.441Z","updated_at":"2025-08-19T17:34:11.441Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018221,"owners_count":26086307,"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-10-14T02:00:06.444Z","response_time":60,"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":["aiohttp","async","asyncio","django","fastapi","starlette"],"created_at":"2024-11-12T23:22:56.151Z","updated_at":"2025-10-14T07:35:07.379Z","avatar_url":"https://github.com/imbolc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Async Django Session\n====================\n\nIt gives you ability to share session between [django][] and an async framework\nlike [aiohttp][], [starlette][], [fastapi][] etc.\n\n    pip install async-django-session\n\nAPI\n---\n\n### Backends\n\nThere's two ways of communicating to database available:\n\n- through [databases][] - which is compatible with most of major RDBMS:\n    ```python\n    database = databases.Database(DB_URI)\n    await database.connect()\n    backend = async_django_session.databases.Backend(database, SECRET_KEY)\n    ```\n- or directly through [asyncpg][] (PostgreSQL only):\n    ```python\n    pool = await asyncpg.create_pool(DB_URI)\n    backend = async_django_session.asyncpg.Backend(pool, SECRET_KEY)\n    ```\n\n### Session\n\nTo fetch session from db by its key there's `backend.get_session` method. If\n`key` is `None` a new session will be created:\n```python\nsession = backend.get_session(key)\n```\nIt's lazy so the session data won't be actually fetched until you call its\n`load` method. In caches the result, so it's inexpensive to call it multiple\ntimes:\n```python\nawait session.load()\n```\nYou can combine them into a single line as the `load` method returns session\nitself:\n```python\nsession = await backend.get_session(key).load()\n```\nSession provides dict-interface to read / write data:\n```python\nsession[\"foo\"] = \"bar\"\nprint(session[\"foo\"])\n```\nTo sync session with database you should explicitly call its `save` method. It\nwon't make unnecessary db call if the session wasn't changed (the boolean value\nit returns is intend to indicate if it was the case).\n```python\nsaved = await session.save()\n```\nDuring saving of a new session a random key will be generated and available as\n`session.key` parameter afterwords.\n\nFrameworks integration\n----------------------\nThere's built-in middlewares for a few frameworks to automatically load (using\nsession id from cookies) and save sessions.\n\n### Aiohttp\nAfter adding of [session middleware][aiohttp middleware]:\n```python\nsession_middleware = async_django_session.aiohttp.middleware(\n    async_django_session.databases.Backend(db, SECRET_KEY)\n)\napp = web.Application(middlewares=[session_middleware])\n```\nYou can get requests session as:\n```python\nsession = await request.get_session()\n```\nA full aiohttp example can be found [here][aiohttp example].\n\n### Starlette\nAfter adding of [session middleware][starlette middleware]:\n```python\nasync_django_session.starlette.middleware(\n    app, async_django_session.databases.Backend(db, SECRET))\n)\n```\nSession of a current request is available as:\n```python\nsession = await request.state.get_session()\n```\n\nA working starlette example is [here][starlette example].\n\n### Fastapi\nPerform starlette app initialization from above as fastapi based on it.\nAfter that you can get session using dependency injection as:\n```python\nfrom async_django_session.fastapi import get_session\nfrom async_django_session.session import Session\n\nasync def index(session: Session = Depends(get_session)):\n    ...\n```\n\nA working fastapi example is [here][fastapi example].\n\nRunning examples\n----------------\nRunning the [examples][] you can see different frameworks using the same session\ndata. To see session data open \u003chttp://localhost:8000/\u003e after running of each\nexample.\n\nInstall requirements:\n\n    cd examples\n    pip install -r requirements.txt\n\nCreate database and tables:\n\n    createdb async_django_session\n    python django_app.py migrate\n\nRun [aiohttp example][] which uses [databases backend][]:\n\n    python aiohttp_app.py\n\nRun [starlette example][] which uses [asyncpg backend][]:\n\n    python starlette_app.py\n\nRun [fastapi example][] which uses [asyncpg backend][]:\n\n    python fastapi_app.py\n\nRun [django example][]:\n\n    python django_app.py runserver\n\n[aiohttp]: https://github.com/aio-libs/aiohttp\n[starlette]: https://github.com/encode/starlette\n[fastapi]: https://github.com/tiangolo/fastapi\n[asyncpg]: https://github.com/MagicStack/asyncpg\n[databases]: https://github.com/encode/databases\n[django]: https://github.com/django/django\n[examples]: https://github.com/imbolc/async_django_session/tree/master/examples\n[django example]: https://github.com/imbolc/async_django_session/tree/master/examples/django_app.py\n[starlette example]: https://github.com/imbolc/async_django_session/tree/master/examples/starlette_app.py\n[fastapi example]: https://github.com/imbolc/async_django_session/tree/master/examples/fastapi_app.py\n[aiohttp example]: https://github.com/imbolc/async_django_session/tree/master/examples/aiohttp_app.py\n[asyncpg backend]: https://github.com/imbolc/async_django_session/tree/master/async_django_session/asyncpg.py\n[databases backend]: https://github.com/imbolc/async_django_session/tree/master/async_django_session/databases.py\n[aiohttp middleware]: https://github.com/imbolc/async_django_session/tree/master/async_django_session/aiohttp.py\n[starlette middleware]: https://github.com/imbolc/async_django_session/tree/master/async_django_session/starlette.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimbolc%2Fasync_django_session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimbolc%2Fasync_django_session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimbolc%2Fasync_django_session/lists"}