flask-Humanify 0.1.4__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {flask_humanify-0.1.4/flask_Humanify.egg-info → flask_humanify-0.2.1}/PKG-INFO +42 -4
  2. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/README.md +36 -3
  3. {flask_humanify-0.1.4 → flask_humanify-0.2.1/flask_Humanify.egg-info}/PKG-INFO +42 -4
  4. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_Humanify.egg-info/SOURCES.txt +8 -2
  5. flask_humanify-0.2.1/flask_Humanify.egg-info/requires.txt +7 -0
  6. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_humanify/__init__.py +1 -1
  7. flask_humanify-0.2.1/flask_humanify/datasets/ai_dogs.pkl +0 -0
  8. flask_humanify-0.2.1/flask_humanify/datasets/animals.pkl +0 -0
  9. flask_humanify-0.2.1/flask_humanify/datasets/characters.pkl +0 -0
  10. flask_humanify-0.2.1/flask_humanify/datasets/keys.pkl +0 -0
  11. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_humanify/features/rate_limiter.py +1 -1
  12. flask_humanify-0.2.1/flask_humanify/humanify.py +697 -0
  13. flask_humanify-0.2.1/flask_humanify/memory_server.py +838 -0
  14. flask_humanify-0.2.1/flask_humanify/templates/audio_challenge.html +208 -0
  15. flask_humanify-0.2.1/flask_humanify/templates/grid_challenge.html +232 -0
  16. flask_humanify-0.1.4/flask_humanify/templates/oneclick_captcha.html → flask_humanify-0.2.1/flask_humanify/templates/one_click_challenge.html +4 -9
  17. flask_humanify-0.2.1/flask_humanify/utils.py +574 -0
  18. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/pyproject.toml +2 -2
  19. flask_humanify-0.1.4/flask_Humanify.egg-info/requires.txt +0 -2
  20. flask_humanify-0.1.4/flask_humanify/humanify.py +0 -158
  21. flask_humanify-0.1.4/flask_humanify/ipset.py +0 -315
  22. flask_humanify-0.1.4/flask_humanify/utils.py +0 -88
  23. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/LICENSE +0 -0
  24. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/MANIFEST.in +0 -0
  25. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_Humanify.egg-info/dependency_links.txt +0 -0
  26. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_Humanify.egg-info/top_level.txt +0 -0
  27. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_humanify/datasets/ipset.json +0 -0
  28. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_humanify/templates/access_denied.html +0 -0
  29. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/flask_humanify/templates/rate_limited.html +0 -0
  30. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/setup.cfg +0 -0
  31. {flask_humanify-0.1.4 → flask_humanify-0.2.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flask-Humanify
3
- Version: 0.1.4
3
+ Version: 0.2.1
4
4
  Summary: Protect against bots and DDoS attacks
5
5
  Author-email: TN3W <tn3w@protonmail.com>
6
6
  License-Expression: Apache-2.0
@@ -27,6 +27,11 @@ Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
28
  Requires-Dist: Flask
29
29
  Requires-Dist: netaddr
30
+ Requires-Dist: opencv-python-headless
31
+ Requires-Dist: numpy
32
+ Requires-Dist: cryptography
33
+ Requires-Dist: scipy
34
+ Requires-Dist: pydub
30
35
  Dynamic: license-file
31
36
 
32
37
  <h1 align="center">flask-Humanify</h1>
@@ -40,10 +45,10 @@ from flask import Flask
40
45
  from flask_Humanify import Humanify
41
46
 
42
47
  app = Flask(__name__)
43
- humanify = Humanify(app)
48
+ humanify = Humanify(app, challenge_type="one_click", image_dataset="ai_dogs")
44
49
 
45
50
  # Register the middleware to deny access to bots
46
- humanify.register_middleware(action="deny_access")
51
+ humanify.register_middleware(action="challenge")
47
52
 
48
53
  @app.route("/")
49
54
  def index():
@@ -56,6 +61,39 @@ if __name__ == "__main__":
56
61
  app.run()
57
62
  ```
58
63
 
64
+ ### Advanced Protection Rules
65
+
66
+ You can customize bot protection with advanced filtering rules:
67
+
68
+ ```python
69
+ # Protect specific endpoints with regex patterns
70
+ humanify.register_middleware(
71
+ action="challenge",
72
+ endpoint_patterns=["api.*", "admin.*"] # Protect all API and admin endpoints
73
+ )
74
+
75
+ # Protect specific URL paths
76
+ humanify.register_middleware(
77
+ action="deny_access",
78
+ url_patterns=["/sensitive/*", "/admin/*"] # Deny bot access to sensitive areas
79
+ )
80
+
81
+ # Exclude certain patterns from protection
82
+ humanify.register_middleware(
83
+ endpoint_patterns=["api.*"],
84
+ exclude_patterns=["api.public.*"] # Don't protect public API endpoints
85
+ )
86
+
87
+ # Filter by request parameters
88
+ humanify.register_middleware(
89
+ request_filters={
90
+ "method": ["POST", "PUT", "DELETE"], # Only protect write operations
91
+ "args.admin": "true", # Only when admin=true query parameter exists
92
+ "headers.content-type": "regex:application/json.*" # Match content type with regex
93
+ }
94
+ )
95
+ ```
96
+
59
97
  Not using the middleware:
60
98
 
61
99
  ```python
@@ -65,7 +103,7 @@ def index():
65
103
  A route that is protected against bots and DDoS attacks.
66
104
  """
67
105
  if humanify.is_bot:
68
- return humanify.deny_access()
106
+ return humanify.challenge()
69
107
  return "Hello, Human!"
70
108
  ```
71
109
 
@@ -9,10 +9,10 @@ from flask import Flask
9
9
  from flask_Humanify import Humanify
10
10
 
11
11
  app = Flask(__name__)
12
- humanify = Humanify(app)
12
+ humanify = Humanify(app, challenge_type="one_click", image_dataset="ai_dogs")
13
13
 
14
14
  # Register the middleware to deny access to bots
15
- humanify.register_middleware(action="deny_access")
15
+ humanify.register_middleware(action="challenge")
16
16
 
17
17
  @app.route("/")
18
18
  def index():
@@ -25,6 +25,39 @@ if __name__ == "__main__":
25
25
  app.run()
26
26
  ```
27
27
 
28
+ ### Advanced Protection Rules
29
+
30
+ You can customize bot protection with advanced filtering rules:
31
+
32
+ ```python
33
+ # Protect specific endpoints with regex patterns
34
+ humanify.register_middleware(
35
+ action="challenge",
36
+ endpoint_patterns=["api.*", "admin.*"] # Protect all API and admin endpoints
37
+ )
38
+
39
+ # Protect specific URL paths
40
+ humanify.register_middleware(
41
+ action="deny_access",
42
+ url_patterns=["/sensitive/*", "/admin/*"] # Deny bot access to sensitive areas
43
+ )
44
+
45
+ # Exclude certain patterns from protection
46
+ humanify.register_middleware(
47
+ endpoint_patterns=["api.*"],
48
+ exclude_patterns=["api.public.*"] # Don't protect public API endpoints
49
+ )
50
+
51
+ # Filter by request parameters
52
+ humanify.register_middleware(
53
+ request_filters={
54
+ "method": ["POST", "PUT", "DELETE"], # Only protect write operations
55
+ "args.admin": "true", # Only when admin=true query parameter exists
56
+ "headers.content-type": "regex:application/json.*" # Match content type with regex
57
+ }
58
+ )
59
+ ```
60
+
28
61
  Not using the middleware:
29
62
 
30
63
  ```python
@@ -34,7 +67,7 @@ def index():
34
67
  A route that is protected against bots and DDoS attacks.
35
68
  """
36
69
  if humanify.is_bot:
37
- return humanify.deny_access()
70
+ return humanify.challenge()
38
71
  return "Hello, Human!"
39
72
  ```
40
73
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flask-Humanify
3
- Version: 0.1.4
3
+ Version: 0.2.1
4
4
  Summary: Protect against bots and DDoS attacks
5
5
  Author-email: TN3W <tn3w@protonmail.com>
6
6
  License-Expression: Apache-2.0
@@ -27,6 +27,11 @@ Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
28
  Requires-Dist: Flask
29
29
  Requires-Dist: netaddr
30
+ Requires-Dist: opencv-python-headless
31
+ Requires-Dist: numpy
32
+ Requires-Dist: cryptography
33
+ Requires-Dist: scipy
34
+ Requires-Dist: pydub
30
35
  Dynamic: license-file
31
36
 
32
37
  <h1 align="center">flask-Humanify</h1>
@@ -40,10 +45,10 @@ from flask import Flask
40
45
  from flask_Humanify import Humanify
41
46
 
42
47
  app = Flask(__name__)
43
- humanify = Humanify(app)
48
+ humanify = Humanify(app, challenge_type="one_click", image_dataset="ai_dogs")
44
49
 
45
50
  # Register the middleware to deny access to bots
46
- humanify.register_middleware(action="deny_access")
51
+ humanify.register_middleware(action="challenge")
47
52
 
48
53
  @app.route("/")
49
54
  def index():
@@ -56,6 +61,39 @@ if __name__ == "__main__":
56
61
  app.run()
57
62
  ```
58
63
 
64
+ ### Advanced Protection Rules
65
+
66
+ You can customize bot protection with advanced filtering rules:
67
+
68
+ ```python
69
+ # Protect specific endpoints with regex patterns
70
+ humanify.register_middleware(
71
+ action="challenge",
72
+ endpoint_patterns=["api.*", "admin.*"] # Protect all API and admin endpoints
73
+ )
74
+
75
+ # Protect specific URL paths
76
+ humanify.register_middleware(
77
+ action="deny_access",
78
+ url_patterns=["/sensitive/*", "/admin/*"] # Deny bot access to sensitive areas
79
+ )
80
+
81
+ # Exclude certain patterns from protection
82
+ humanify.register_middleware(
83
+ endpoint_patterns=["api.*"],
84
+ exclude_patterns=["api.public.*"] # Don't protect public API endpoints
85
+ )
86
+
87
+ # Filter by request parameters
88
+ humanify.register_middleware(
89
+ request_filters={
90
+ "method": ["POST", "PUT", "DELETE"], # Only protect write operations
91
+ "args.admin": "true", # Only when admin=true query parameter exists
92
+ "headers.content-type": "regex:application/json.*" # Match content type with regex
93
+ }
94
+ )
95
+ ```
96
+
59
97
  Not using the middleware:
60
98
 
61
99
  ```python
@@ -65,7 +103,7 @@ def index():
65
103
  A route that is protected against bots and DDoS attacks.
66
104
  """
67
105
  if humanify.is_bot:
68
- return humanify.deny_access()
106
+ return humanify.challenge()
69
107
  return "Hello, Human!"
70
108
  ```
71
109
 
@@ -10,10 +10,16 @@ flask_Humanify.egg-info/requires.txt
10
10
  flask_Humanify.egg-info/top_level.txt
11
11
  flask_humanify/__init__.py
12
12
  flask_humanify/humanify.py
13
- flask_humanify/ipset.py
13
+ flask_humanify/memory_server.py
14
14
  flask_humanify/utils.py
15
+ flask_humanify/datasets/ai_dogs.pkl
16
+ flask_humanify/datasets/animals.pkl
17
+ flask_humanify/datasets/characters.pkl
15
18
  flask_humanify/datasets/ipset.json
19
+ flask_humanify/datasets/keys.pkl
16
20
  flask_humanify/features/rate_limiter.py
17
21
  flask_humanify/templates/access_denied.html
18
- flask_humanify/templates/oneclick_captcha.html
22
+ flask_humanify/templates/audio_challenge.html
23
+ flask_humanify/templates/grid_challenge.html
24
+ flask_humanify/templates/one_click_challenge.html
19
25
  flask_humanify/templates/rate_limited.html
@@ -0,0 +1,7 @@
1
+ Flask
2
+ netaddr
3
+ opencv-python-headless
4
+ numpy
5
+ cryptography
6
+ scipy
7
+ pydub
@@ -4,7 +4,7 @@ Flask-Humanify
4
4
  A Flask extension that protects against bots and DDoS attacks.
5
5
  """
6
6
 
7
- __version__ = "0.1.4"
7
+ __version__ = "0.2.1"
8
8
 
9
9
  from . import utils
10
10
  from .humanify import Humanify
@@ -11,7 +11,7 @@ class RateLimiter:
11
11
  Rate limiter.
12
12
  """
13
13
 
14
- def __init__(self, app=None, max_requests: int = 2, time_window: int = 10):
14
+ def __init__(self, app=None, max_requests: int = 10, time_window: int = 10):
15
15
  """
16
16
  Initialize the rate limiter.
17
17
  """