-
Notifications
You must be signed in to change notification settings - Fork 758
Closed
Labels
FOSSHack 2026FOSSHack 2026 HackathonFOSSHack 2026 HackathonbackendFlask backend issuesFlask backend issuesdocumentationImprovements or additions to documentationImprovements or additions to documentationgood first issueGood for newcomersGood for newcomers
Description
Description
The `utils/security_middleware.py` module implements critical security functionality (IP banning, WSGI middleware) but lacks type hints and docstrings, making it harder for new contributors to understand.
Affected File
- `utils/security_middleware.py`
What to Do
- Add type hints to `SecurityMiddleware.init` and `call`
- Add type hints to `check_ip_ban` decorator
- Add class-level and function-level docstrings
```python
from typing import Any, Callable
class SecurityMiddleware:
"""WSGI middleware that checks if the client IP is banned before processing requests."""
def __init__(self, app: Any) -> None:
\"\"\"Initialize middleware with the WSGI application.\"\"\"
self.app = app
def __call__(self, environ: dict[str, Any], start_response: Callable) -> Any:
\"\"\"Check IP ban status and either block or forward the request.\"\"\"
...
def check_ip_ban(f: Callable[..., Any]) -> Callable[..., Any]:
"""Decorator that returns 403 if the client IP is banned."""
...
```
Acceptance Criteria
- All public methods have type hints
- All classes and functions have docstrings
- Type hints are accurate (verify parameter/return types)
Skills You'll Learn
- Python type hints for WSGI apps
- Writing effective docstrings
- Understanding middleware patterns
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FOSSHack 2026FOSSHack 2026 HackathonFOSSHack 2026 HackathonbackendFlask backend issuesFlask backend issuesdocumentationImprovements or additions to documentationImprovements or additions to documentationgood first issueGood for newcomersGood for newcomers