{"id":15019704,"url":"https://github.com/tethik/flask-session-captcha","last_synced_at":"2025-04-05T19:13:57.514Z","repository":{"id":22546728,"uuid":"96036348","full_name":"Tethik/flask-session-captcha","owner":"Tethik","description":"A captcha implemention for flask","archived":false,"fork":false,"pushed_at":"2024-10-28T17:13:30.000Z","size":437,"stargazers_count":24,"open_issues_count":3,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T19:13:34.016Z","etag":null,"topics":["captcha","flask"],"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/Tethik.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-02T16:41:03.000Z","updated_at":"2024-10-28T17:13:31.000Z","dependencies_parsed_at":"2024-03-18T16:44:47.939Z","dependency_job_id":"ac88388f-9e45-43e6-8697-57c761af40fe","html_url":"https://github.com/Tethik/flask-session-captcha","commit_stats":{"total_commits":140,"total_committers":12,"mean_commits":"11.666666666666666","dds":0.7857142857142857,"last_synced_commit":"baa0812eb0c494285e34570dd351d0a21e7bb520"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tethik%2Fflask-session-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tethik%2Fflask-session-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tethik%2Fflask-session-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tethik%2Fflask-session-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tethik","download_url":"https://codeload.github.com/Tethik/flask-session-captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386266,"owners_count":20930619,"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":["captcha","flask"],"created_at":"2024-09-24T19:53:54.817Z","updated_at":"2025-04-05T19:13:57.479Z","avatar_url":"https://github.com/Tethik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# flask-session-captcha\n\n[![Latest version](https://img.shields.io/pypi/v/flask-session-captcha.svg)](https://pypi.python.org/pypi/flask-session-captcha)\n[![Supported python versions](https://img.shields.io/pypi/pyversions/flask-session-captcha.svg)](https://pypi.python.org/pypi/flask-session-captcha)\n[![License](https://img.shields.io/github/license/Tethik/flask-session-captcha.svg)](https://github.com/Tethik/flask-session-captcha/blob/master/LICENSE)\n\n[![Downloads](https://static.pepy.tech/badge/flask-session-captcha)](https://pepy.tech/project/flask-session-captcha)\n[![Downloads](https://static.pepy.tech/badge/flask-session-captcha/month)](https://pepy.tech/project/flask-session-captcha)\n[![Downloads](https://static.pepy.tech/badge/flask-session-captcha/week)](https://pepy.tech/project/flask-session-captcha)\n\n****\nA captcha implemention for flask using [flask-session](https://pypi.python.org/pypi/Flask-Session/) and [captcha](https://pypi.python.org/pypi/captcha/) packages. \nEach captcha challenge answer is saved in the server side session of the challenged client.\nSupport for different types of captchas such as numeric/letter/symbol captchas.\n\n## Requirements\n* [Flask](https://pypi.python.org/pypi/Flask/)\n* [flask-session](https://pypi.python.org/pypi/Flask-Session/) with packages depending on which SESSION_TYPE you use. E.g. sqlalchemy requires flask-sqlalchemy.\n* [captcha](https://pypi.python.org/pypi/captcha/)\n\n## Changelog\n\n* **1.5.0** - adds two new methods `revoke_answer` and `set_answer` to plugin `FlaskSessionCaptcha` class. Removes `set_in_session` method.\n* **1.4.2** - Bump pillow from 10.2.0 to 10.3.0 by @dependabot in #49\n* **1.4.1** - Fix error thrown when flask-session-captcha is init-ed without a Flask app object. Rename CAPTCHA_LOG environment variable to CAPTCHA_DEBUG_LOG.\n* **1.4.0** - Migrated from `flask-sessionstore` to `flask-session`. Added functionality for alphabetic and punctuation characters to be included in the captcha (thanks @alisharify7). Support moved to python 3.8, 3.9, 3.10, 3.11.\n\n## Usage\n```python\nimport uuid\nimport logging\nfrom flask import Flask, request, render_template\nfrom flask_session import Session\nfrom flask_session_captcha import FlaskSessionCaptcha\n\napp = Flask(__name__)\napp.config[\"SECRET_KEY\"] = uuid.uuid4().hex\n\n# captcha configs:\napp.config['CAPTCHA_ENABLE'] = True\napp.config['CAPTCHA_LENGTH'] = 5\napp.config['CAPTCHA_WIDTH'] = 200\napp.config['CAPTCHA_HEIGHT'] = 160\n# app.config['CAPTCHA_LOG'] = False # log information to terminal\n# app.config['CAPTCHA_INCLUDE_ALPHABET'] = False\n# app.config['CAPTCHA_INCLUDE_NUMERIC'] = True\n# app.config['CAPTCHA_INCLUDE_PUNCTUATION'] = False\n# app.config['CAPTCHA_SESSION_KEY'] = 'captcha_image' # In case you want to use another key in your session to store the captcha\n\n# session config\napp.config['SESSION_TYPE'] = 'redis' # or other type of drivers for session, see https://flask-session.readthedocs.io/en/latest/\nSession(app)\ncaptcha = FlaskSessionCaptcha(app)\n\n@app.route('/', methods=['POST','GET'])\ndef some_route():\n    if request.method == \"POST\":\n        if captcha.validate():\n            return \"captcha validated successfully\"\n        else:\n            return \"invalid captcha/answer\"\n\n    return render_template(\"form.html\")\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n```\n\n\nTemplate can look as follows. `captcha.validate()` will be default try to validate against a form input with name \"captcha\".\n\n```html\n\u003cform method=\"POST\"\u003e\n    {{ captcha() }} \u003c!-- This renders an \u003cimg\u003e tag with the captcha img. --\u003e\n    \u003cinput type=\"text\" name=\"captcha\"\u003e\n    \u003cinput type=\"submit\"\u003e\n\u003c/form\u003e\n```\n\nIt can also take a `css_class` argument to add classes to the generated DOM:\n\n```html\n\u003cform method=\"POST\"\u003e\n    {{ captcha(css_class=\"captcha\") }}\n    \u003cinput type=\"text\" name=\"captcha\"\u003e\n    \u003cinput type=\"submit\"\u003e\n\u003c/form\u003e\n```\n\nYou can also override settings for the captcha contents itself, via `include_alphabet`, `include_numeric` and `include_punctuation`.\nLike so:\n\n```html\n\u003cform method=\"POST\"\u003e\n    {{ captcha(include_alphabet=True) }}\n    \u003cinput type=\"text\" name=\"captcha\"\u003e\n    \u003cinput type=\"submit\"\u003e\n\u003c/form\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftethik%2Fflask-session-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftethik%2Fflask-session-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftethik%2Fflask-session-captcha/lists"}