Repository navigation
add rate limiting across auth, user, staff, and order endpoints - #43
Conversation
AkibDa
commented
Feb 3, 2026
- Integrated SlowAPI middleware
- Protected payment, cancel, and resale flows
- Added cost-safe limits for AI and upload endpoints
| @app.post('/auth/verify-staff', tags=["auth"]) | ||
| async def verify_staff_endpoint(credentials: HTTPAuthorizationCredentials = Security(security)): | ||
| @limiter.limit("5/minute") | ||
| async def verify_staff_endpoint( |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Missing function or method docstring Warning
| @app.post('/auth/verify-student', tags=["auth"]) | ||
| async def verify_student_endpoint(credentials: HTTPAuthorizationCredentials = Security(security)): | ||
| @limiter.limit("5/minute") | ||
| async def verify_student_endpoint( |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Missing function or method docstring Warning
There was a problem hiding this comment.
Prospector (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Pylint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
| from .webhook import router as webhook_router | ||
|
|
||
| def rate_limit_key(request: Request): | ||
| auth_header = request.headers.get("authorization") |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
| def rate_limit_key(request: Request): | ||
| auth_header = request.headers.get("authorization") | ||
|
|
||
| if auth_header: |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
| auth_header = request.headers.get("authorization") | ||
|
|
||
| if auth_header: | ||
| token_hash = hashlib.sha256(auth_header.encode()).hexdigest() |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 4 spaces, expected 8 Note
|
|
||
| if auth_header: | ||
| token_hash = hashlib.sha256(auth_header.encode()).hexdigest() | ||
| return f"user:{token_hash}" |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 4 spaces, expected 8 Note
| token_hash = hashlib.sha256(auth_header.encode()).hexdigest() | ||
| return f"user:{token_hash}" | ||
|
|
||
| forwarded = request.headers.get("x-forwarded-for") |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
| return f"user:{token_hash}" | ||
|
|
||
| forwarded = request.headers.get("x-forwarded-for") | ||
| if forwarded: |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
|
|
||
| forwarded = request.headers.get("x-forwarded-for") | ||
| if forwarded: | ||
| return f"ip:{forwarded.split(',')[0].strip()}" |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 4 spaces, expected 8 Note
| if forwarded: | ||
| return f"ip:{forwarded.split(',')[0].strip()}" | ||
|
|
||
| return f"ip:{request.client.host}" |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
| from .webhook import router as webhook_router | ||
|
|
||
| def rate_limit_key(request: Request): | ||
| """ |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
| def health_check(request: Request): | ||
| """ | ||
| Health check endpoint for monitoring service availability. | ||
| """ |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
| """ | ||
| _ = request | ||
| return { | ||
| "status": "ok", |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note
| _ = request | ||
| return { | ||
| "status": "ok", | ||
| "service": "greenplate-backend", |
Check notice
Code scanning / Pylintpython3 (reported by Codacy)
Bad indentation. Found 2 spaces, expected 4 Note