feat: Add FastAPI Security Cheat Sheet#1971
feat: Add FastAPI Security Cheat Sheet#1971Sikandar1310291 wants to merge 2 commits intoOWASP:masterfrom
Conversation
szh
left a comment
There was a problem hiding this comment.
We should really have someone familiar with FastAPI review this.
|
|
||
| - [FastAPI Security Documentation](https://fastapi.tiangolo.com/tutorial/security/) | ||
| - [OWASP API Security Top 10](https://owasp.org/www-project-api-security/) | ||
| - [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/) |
There was a problem hiding this comment.
Seems kind of strange to link to the project itself
The value of this PR is to provide a dedicated security resource for the rapidly growing FastAPI ecosystem, filling a specific gap in the current OWASP Cheat Sheet Series. While generic API security principles apply, FastAPI introduces unique architectural patterns that require specific security guidance not found in other Python (Flask/Django) or generic guides: Dependency Injection Security: It guides developers on using FastAPI's dependency injection system for consistent authentication & authorization (e.g., Depends(get_current_user)), which is the framework's primary way of handling security. Pydantic & Type Hinting: It demonstrates how to leverage Pydantic models (specifically Field constraints and types) for strict input validation, a core part of FastAPI that differs from other frameworks. Default Misconfigurations: It addresses FastAPI-specific defaults that can be insecure in production, such as the automatically generated Swagger UI (/docs) and providing concrete code to secure or disable them. Async/ASGI Context: It covers security configurations specific to the ASGI/Uvicorn deployment model, which differs from the traditional WSGI approach. |
|
Thanks for taking the time to put together this PR — I appreciate the effort and the solid FastAPI examples included here. That said, I want to clarify that this PR is somewhat different from what I originally proposed in the issue. (#1969) My original intent for the FastAPI Security Cheat Sheet was not primarily to document how to use FastAPI security features, but rather to focus on:
The current content is closer to an implementation-oriented best practices guide, which overlaps significantly with existing FastAPI documentation and general API security guidance. I think this PR could still be valuable with a shift in focus toward:
Happy to discuss how we can align this PR with the original scope, or whether it makes sense to treat this as a separate contribution. |
|
@web4akash Thank you for the detailed feedback and clarification on the original intent of issue #1969. I completely understand your perspective now. You're right that the current PR leans more heavily toward implementation-oriented best practices rather than focusing on threat modeling and real-world misuse cases. I appreciate you laying out this distinction so clearly. Looking at your suggestions, I think there are a few paths forward:
I'm leaning toward option 1, as it seems closer to the OWASP Cheat Sheet Series philosophy of addressing "what can go wrong" and how to defend against it. Would you be open to collaborating on restructuring this? I can start refactoring the content based on these principles and get your feedback before finalizing. |
You're A Rockstar
Thank you for submitting a Pull Request (PR) to the Cheat Sheet Series.
Please make sure that for your contribution:
[TEXT](URL)If your PR is related to an issue, please finish your PR text with the following line:
This PR fixes issue #1969.
AI Tool Usage Disclosure (required for all PRs)
Please select one of the following options:
the contents and I affirm the results. The LLM used is
Gemini 2.5 Proand the prompt used is
Create a FastAPI Security Cheat Sheet based on issue #1969.Thank you again for your contribution 😃