{"id":23537512,"url":"https://github.com/py-package/masonite-security","last_synced_at":"2025-04-23T14:14:44.348Z","repository":{"id":46269424,"uuid":"513813420","full_name":"py-package/masonite-security","owner":"py-package","description":"Secure masonite apps from spamming Bots, IP's and SQL injections.","archived":false,"fork":false,"pushed_at":"2024-02-05T01:07:20.000Z","size":94,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T14:14:36.557Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/py-package.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-14T08:06:28.000Z","updated_at":"2024-08-22T12:39:53.000Z","dependencies_parsed_at":"2022-08-30T20:42:20.333Z","dependency_job_id":null,"html_url":"https://github.com/py-package/masonite-security","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-security","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-security/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-security/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-security/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/py-package","download_url":"https://codeload.github.com/py-package/masonite-security/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250447979,"owners_count":21432165,"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":[],"created_at":"2024-12-26T03:16:12.455Z","updated_at":"2025-04-23T14:14:44.329Z","avatar_url":"https://github.com/py-package.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://banners.beyondco.de/Masonite%20Security.png?theme=light\u0026packageManager=pip+install\u0026packageName=masonite-security\u0026pattern=charlieBrown\u0026style=style_2\u0026description=Secure+masonite+apps+from+spamming+Bots,+IP's+and+SQL+injections.\u0026md=1\u0026showWatermark=1\u0026fontSize=100px\u0026images=adjustments\u0026widths=50\u0026heights=50\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://docs.masoniteproject.com\"\u003e\n    \u003cimg alt=\"Masonite Package\" src=\"https://img.shields.io/static/v1?label=Masonite\u0026message=package\u0026labelColor=grey\u0026color=blue\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAA6gAwAEAAAAAQAAAA4AAAAATspU+QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cm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D3mJeXqxQevB4prrqgc0TmQ85NG/K43e2UwnMVAJIEBNfWRYR3HfnvivrIzMyo4Hgy+hfscvLo53jItAAAAABJRU5ErkJggg==\"\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"GitHub Workflow Status (branch)\" src=\"https://github.com/py-package/masonite-security/actions/workflows/pythonapp.yml/badge.svg\"\u003e\n  \u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/masonite-security\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/python-3.7+-blue.svg\" alt=\"Python Version\"\u003e\n  \u003cimg alt=\"GitHub release (latest by date including pre-releases)\" src=\"https://img.shields.io/github/v/release/py-package/masonite-security?include_prereleases\"\u003e\n  \u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/py-package/masonite-security\"\u003e\n  \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Masonite Security\n\nSecure masonite apps from spamming Bots, IP's and SQL injections.\n\n## Features\n\n- [x] Block IP's\n- [x] Block Bots\n- [x] Throttle Requests\n- [ ] Block SQL Injections\n\n## Installation\n\n```bash\npip install masonite-security\n```\n\n## Configuration\n\nAdd SecurityProvider to your project in `config/providers.py`:\n\n```python\n# config/providers.py\n# ...\nfrom security import SecurityProvider\n\n# ...\nPROVIDERS = [\n    # ...\n    # Third Party Providers\n    SecurityProvider,\n    # ...\n]\n```\n\nThen you can publish the package resources by doing:\n\n```bash\npython craft package:publish security\n```\n\n## Register Middleware.\n\nYou can setup the security middleware globally or per route basis.\n\n**Global Setup**\n\nOpen `Kernal.py` file and add `SecurityMiddleware` in \"route_middleware\" section:\n\n```python\nroute_middleware = {\n      \"web\": [SessionMiddleware, LoadUserMiddleware, VerifyCsrfToken, SecurityMiddleware],\n      \"auth\": [AuthenticationMiddleware],\n  }\n```\n\n**Per Route Setup**\n\nIn your routes add `protect` middleware like this:\n\n```python\nRoute.get(\"/\", \"WelcomeController@show\").middleware(\"protect\")\n```\n\n## Configure Security Config\n\nUpdate your `config/security.py` file based on your needs:\n\n```python\n# config/security.py\n# ...\nBLOCK_IP = True\nBLOCK_BOTS = True\nTHROTTLE_REQUESTS = True\n\nMAX_REQUESTS = 20 # Max requests per IP (default: 20)\nIP_BLOCK_DURATION = 60  # seconds (default: 60)\n\n# list of IP addresses to block (default: [])\nBLOCKED_IPS = [\n  #...\n]\n\n# list of Bot Agents to block\nBLOCKED_BOTS = [\n    #...\n]\n# ...\n```\n\n## Contributing\n\nPlease read the [Contributing Documentation](CONTRIBUTING.md) here.\n\n## Maintainers\n\n- [x] [Yubaraj Shrestha](https://www.github.com/py-package)\n\n## License\n\nsecurity is open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpy-package%2Fmasonite-security","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpy-package%2Fmasonite-security","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpy-package%2Fmasonite-security/lists"}