{"id":31822893,"url":"https://github.com/devfans/redis-session","last_synced_at":"2025-10-11T14:20:17.445Z","repository":{"id":57460704,"uuid":"144700961","full_name":"devfans/redis-session","owner":"devfans","description":"Implementation for web sessions with redis as datastore","archived":false,"fork":false,"pushed_at":"2018-10-03T08:55:01.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-22T14:49:52.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/devfans.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2018-08-14T09:48:37.000Z","updated_at":"2023-01-05T06:51:55.000Z","dependencies_parsed_at":"2022-09-17T04:22:03.534Z","dependency_job_id":null,"html_url":"https://github.com/devfans/redis-session","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devfans/redis-session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devfans%2Fredis-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devfans%2Fredis-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devfans%2Fredis-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devfans%2Fredis-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devfans","download_url":"https://codeload.github.com/devfans/redis-session/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devfans%2Fredis-session/sbom","scorecard":{"id":337430,"data":{"date":"2025-08-11","repo":{"name":"github.com/devfans/redis-session","commit":"974cc1e2d7e9e064acafc5da2539c50cdfa86c82"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"Code-Review","score":0,"reason":"Found 0/21 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":"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":"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":"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":"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":"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":"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":"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":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"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":"22 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-66 / GHSA-562c-5r94-xh97","Warn: Project is vulnerable to: PYSEC-2019-179 / GHSA-5wv5-4vpf-pj6m","Warn: Project is vulnerable to: PYSEC-2023-62 / GHSA-m2qf-hxjv-5gpq","Warn: Project is vulnerable to: GHSA-753j-mpmx-qq6g","Warn: Project is vulnerable to: GHSA-7cx3-6m66-7c5m","Warn: Project is vulnerable to: PYSEC-2020-213 / GHSA-8vpw-mgpf-mpvv","Warn: Project is vulnerable to: GHSA-8w49-h785-mj3c","Warn: Project is vulnerable to: PYSEC-2012-5 / GHSA-f7fv-v9rh-prvc","Warn: Project is vulnerable to: PYSEC-2023-75 / GHSA-hj3f-6gcp-jg8j","Warn: Project is vulnerable to: GHSA-qppv-j76h-2rpx","Warn: Project is vulnerable to: GHSA-w235-7p84-xx57","Warn: Project is vulnerable to: GHSA-2g68-c3qc-8985","Warn: Project is vulnerable to: PYSEC-2020-157 / GHSA-3p3h-qghp-hvh2","Warn: Project is vulnerable to: GHSA-f9vj-2wh5-fj8j","Warn: Project is vulnerable to: PYSEC-2019-140 / GHSA-gq9m-qvpx-68hc","Warn: Project is vulnerable to: PYSEC-2017-43 / GHSA-h2fp-xgx6-xh6f","Warn: Project is vulnerable to: PYSEC-2023-221 / GHSA-hrfv-mqp8-q5rw","Warn: Project is vulnerable to: GHSA-j544-7q9p-6xp8","Warn: Project is vulnerable to: PYSEC-2023-57 / GHSA-px8h-6qxv-m22q","Warn: Project is vulnerable to: GHSA-q34m-jh98-gwm2","Warn: Project is vulnerable to: PYSEC-2023-58 / GHSA-xg9f-g7g7-2323","Warn: Project is vulnerable to: PYSEC-2022-203"],"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-18T05:03:21.143Z","repository_id":57460704,"created_at":"2025-08-18T05:03:21.144Z","updated_at":"2025-08-18T05:03:21.144Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007496,"owners_count":26084313,"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-11T02:00:06.511Z","response_time":55,"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":[],"created_at":"2025-10-11T14:20:12.733Z","updated_at":"2025-10-11T14:20:17.440Z","avatar_url":"https://github.com/devfans.png","language":"Python","readme":"# redis-session\nWeb session implementation with redis store\n\n[![PYPI Version][pypi-image]][pypi-url]\n[![Build Status][travis-image]][travis-url]\n\n\n## Description\nImplementated for python3 web frameworks to handle client sessions(Tornado and Flask are supported, other web frameworks to be supported later), using redis hashes to save session data.\n\n+ For controlling expiration of sessions, we are using redis key expiration, and we only control session expiration at server/database side, while using default expiration time of secure cookies for session ids.\n\n+ Reading session data in a request will cause a session expiration reset per request. Modify session data will cause a reset per modification.\n\n+ Please specify `cookie_secret`(`SECRET_KEY` for flask) for we are using secure cookie keys.\n\n+ Getting session attributes is achived by directly fetching from redis to avoid stale data being read. So, when it's not necessary, copy the data instead of reading again, which means:\n```\n(Example of tornado)\n# Do this\nname = self.session.name.str\nnames.append(name)\nself.session.name = make_new_name(name)\n# Instead of (When we are not worried about conflicts with other processes/threads)\nnames.append(self.session.name.str)\nself.session.name = make_new_name(self.session.name.str)  # This will read name from redis again\n```\n\n\n## Setup \u0026 Install\n\n#### Via pip\n\n```\npip install redis_session\n```\n\n#### From source\n\n```\npython setup.py build \u0026\u0026 python setup.py install\n```\n\n## Session data parsing\nWe provide common redis result parsing methods. For example:\n\n```\n# Get raw bytes\nself.session.name.raw         # b'stefan'\n\n# Parsing to types\nself.session.name.str         # Fallback to ''\nself.session.count.int        # Fallback to 0\nself.session.vip.bool         # Fallback to False\nself.session.properties.json  # Fallback to {}\n\n# Check if is none\nself.session.age.none\n \n```\n\n\n## Tornado\n\n+ We are using tornado.options module, so please run below once at start.\n```\ntornado.options.parse_command_line()\n# or\ntornado.options.parse_config_file(\"/etc/server.conf\")\n```\n### Command line parameters\n\n```\n# For tornado users\ndefine('session-redis', default='redis://localhost:6379', help='session store redis url', type=str)\ndefine('session-redis-prefix', help='redis key prefix', type=str)\ndefine('session-expire', help='session ttl(seconds)', type=int)\ndefine('session-cookie-id', help='cookie key, default: session-id', type=str)\ndefine('session-cookie-secure', default=True, help='if use secure session cookie', type=bool)\ndefine('session-cookie-domain', default='', help='session cookie domain', type=str)\ndefine('session-cookie-path', default='/', help='session cookie path', type=str)\ndefine('session-cookie-http-only', default=True, help='if set session cookie as http only', type=bool)\n```\n\n### Example\n\n```\n# With tornado framework\n\nimport tornado.web\nimport tornado.httpserver\nimport tornado.ioloop\nfrom tornado.options import options, define, parse_command_line\nfrom redis_session.tornado_session import SessionHandler\n\ndefine('port', default=3000, help='run on the given port', type=int)\ndefine('debug', default=False, help='run in debug mode')\n\nclass MainHandler(SessionHandler):\n    def get(self):\n        count = self.session.count.int\n        self.write(f'Current session value of count:{count}\\n')\n        self.session.count = count + 1\n        self.write(f'Current session value of count:{self.session.count.int}\\n')\n\ndef main():\n    parse_command_line()\n    application = tornado.web.Application([(r'/', MainHandler)], cookie_secret='udxas-efasx-ase323fs-3efsxf3eFdes')\n    http_server = tornado.httpserver.HTTPServer(application)\n    http_server.listen(options.port)\n    tornado.ioloop.IOLoop.instance().start()\n\nif __name__ == '__main__':\n    main()\n```\n\n## Flask\n\nPlease note `httpOnly` for flask session cookie is not well implementated in this project yet.\n\n### Example\n```\nfrom redis_session.flask_session import setup_session\nfrom flask import Flask, request\n\napp = Flask(__name__)\n\n@app.route('/')\ndef handle():\n    count = request.session.count.int\n    res = f'Current session value of count:{count}\\n'\n    request.session.count = count + 1\n    res += f'Current session value:{request.session.count.int}\\n'\n    return res\n\n\ndef main():\n    app.config.from_mapping(\n        ENV='dev',\n        SECRET_KEY='demo',\n        SESSION_REDIS='redis://localhost:6379',\n        SESSION_REDIS_PREFIX='appName',\n        SESSION_COOKIE_ID='app-session-id',\n        SESSION_COOKIE_HTTP_ONLY = True,\n        SESSION_COOKIE_SECURE = False,\n        SESSION_COOKIE_DOMAIN = '.mydomain.com',\n        SESSION_COOKIE_PATH = '/',\n        SESSION_EXPIRE=60*60*24*7\n    )\n    setup_session(app)\n    app.run(port=3000)\n\nif __name__ == \"__main__\":\n    main()\n```\n\n[pypi-image]: https://img.shields.io/pypi/v/redis-session.svg\n[pypi-url]: https://pypi.org/project/redis-session/\n[travis-image]: https://img.shields.io/travis/devfans/redis-session/master.svg\n[travis-url]: https://travis-ci.org/devfans/redis-session\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevfans%2Fredis-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevfans%2Fredis-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevfans%2Fredis-session/lists"}