{"id":24569036,"url":"https://github.com/riton/flask-encrypted-cookies-session","last_synced_at":"2026-04-28T17:02:03.452Z","repository":{"id":159323142,"uuid":"634619381","full_name":"riton/flask-encrypted-cookies-session","owner":"riton","description":"An encrypted cookie based session implementation for flask (mirror of https://gitlab.in2p3.fr/rferrand/flask-encrypted-cookies-session for Pull Requests and issues)","archived":false,"fork":false,"pushed_at":"2023-04-30T18:28:27.000Z","size":68,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-09-11T17:19:17.167Z","etag":null,"topics":["fernet-cryptography","flask","session-management"],"latest_commit_sha":null,"homepage":"","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/riton.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-04-30T18:00:48.000Z","updated_at":"2024-03-28T17:50:58.000Z","dependencies_parsed_at":"2023-06-12T10:15:08.092Z","dependency_job_id":null,"html_url":"https://github.com/riton/flask-encrypted-cookies-session","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/riton/flask-encrypted-cookies-session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riton%2Fflask-encrypted-cookies-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riton%2Fflask-encrypted-cookies-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riton%2Fflask-encrypted-cookies-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riton%2Fflask-encrypted-cookies-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riton","download_url":"https://codeload.github.com/riton/flask-encrypted-cookies-session/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riton%2Fflask-encrypted-cookies-session/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32390067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: 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":["fernet-cryptography","flask","session-management"],"created_at":"2025-01-23T14:56:05.523Z","updated_at":"2026-04-28T17:02:03.444Z","avatar_url":"https://github.com/riton.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#\n\n[![pipeline status](https://gitlab.in2p3.fr/rferrand/flask-encrypted-cookies-session/badges/develop/pipeline.svg)](https://gitlab.in2p3.fr/rferrand/flask-encrypted-cookies-session/-/commits/develop)\n[![coverage report](https://gitlab.in2p3.fr/rferrand/flask-encrypted-cookies-session/badges/develop/coverage.svg)](https://gitlab.in2p3.fr/rferrand/flask-encrypted-cookies-session/-/commits/develop)\n[![black badge](https://img.shields.io/badge/code%20style-black-000000.svg)](https://img.shields.io/badge/code%20style-black-000000.svg)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n\n## Description\n\nA cookie based session for `flask` relying on `Fernet` encrypted cookies.\n\n### Motivation\n\n`flask` default session rely on _signed cookies_. This sometimes is not enough, and encrypted data should be used.\n\n_Example_ : Use cookies to store OAuth2 _access tokens_ without the burden of server side storage.\n\n\n## Usage\n\n### Installation\n\n`pip install flask-encrypted-cookies-session`\n\n\n### Flask application configuration\n\nPrivate key used to encrypt cookies can be generated with `python -c \"from cryptography.fernet import Fernet; print(Fernet.generate_key())\"`\n\n```python\n# -*- coding: utf-8 -*-\nfrom flask import Flask, session\n\nfrom flask_encrypted_cookies_session import EncryptedCookieSession\n\nDEBUG = \"True\"\nENCRYPTED_COOKIES_SECRET_KEY = (\n    \"JNJQuYdaUGr8XBSoZNYF9FC-A7RZ7iFqV_KqrCwYr0s=\"  # Fernet.generate_key()\n)\n# To rotate your keys:\n# ENCRYPTED_COOKIES_SECRET_KEY = \"JNJQuYdaUGr8XBSoZNYF9FC-A7RZ7iFqV_KqrCwYr0s=,Dfo2hCeG-S6CeY-_tgJ33gip9rxC2t8qNK0CM0gZlRk=\"  # [Fernet.generate_key(), Fernet.generate_key()]\n\napp = Flask(__name__)\napp.config.from_object(__name__)\n\n# This will replace the default Flask application session interface with the encrypted\n# cookie based session\nEncryptedCookieSession(app)\n\n\n@app.route(\"/set/\")\ndef session_set():\n    session[\"key\"] = \"value\"\n    return \"ok\"\n\n\n@app.route(\"/get/\")\ndef session_get():\n    return session.get(\"key\", \"not set\")\n```\n\n## Development\n\n[`poetry`](https://python-poetry.org/) is used to manage this project.\n\n[`poe the poet`](https://github.com/nat-n/poethepoet) is used as the _task runner_ of this project. If you don't know what a _task runner_ is, think about an alternative version of a `Makefile`.\n\n### Install project dependencies\n\n```\n$ poetry install\n```\n\n### Unit testing\n\n#### Test with all python versions\n\n```\n$ poe test\n```\n\n#### Test with a specific python version\n\n```\n$ poe test-py39\n```\n\n## F.A.Q\n\n### Where can I open an _Issue_ or a _Pull Request_ to contribute ?\n\nThe [github repository](https://github.com/riton/flask-encrypted-cookies-session) should be used for _Issues_ or _contributions_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friton%2Fflask-encrypted-cookies-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friton%2Fflask-encrypted-cookies-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friton%2Fflask-encrypted-cookies-session/lists"}