Secure REST API
REST API built by a team of 4 as part of the IT & Information Systems Expert certification, with particular attention to security.
SQLAlchemy
OAuth2
+5
Show details
Goal: Apply security best practices from the design of an API onward.
What I did
- Layered architecture: routers, services and repositories
- OAuth2 authentication (OAuth2PasswordBearer) with JWT tokens and role-based access control (RBAC), handling 401 and 403 errors
- Passwords hashed with Argon2, sensitive customer data encrypted with AES using the Cryptography library
- Interface contract validation with Pydantic schemas: types, formats and required fields checked, protection against injection
- Rate limiting and maximum request size
- Pytest unit and integration tests, Swagger documentation
Tests
- Unit Pytest tests of the service logic
- Integration Pytest tests of the API routes, from request to database
Security · OWASP
- A01 Broken access control : Role-based access control (RBAC) on every route, with distinct 401 and 403 responses
- A04 Cryptographic failures : AES encryption of customer contact details and other sensitive data (Cryptography)
- A05 Injection : Interface contract validation with Pydantic and anti-injection checks on incoming data
- A07 Authentication failures : OAuth2 authentication with JWT tokens, passwords hashed with Argon2
- API4 Unrestricted resource consumption : Rate limiting and maximum request size
Full stack list
SQLAlchemy
OAuth2
Argon2
Cryptography (AES)