How do you secure REST APIs in Django?
Instruction: Discuss the strategies to secure REST APIs built with Django REST Framework.
Context: This question examines the candidate's understanding of API security practices and their ability to apply them in Django REST Framework.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Separate identity, authorization, input rules and availability controls. Use HTTPS and a supported authentication scheme suited to the client. A signed JWT is not automatically safer than a server-side session or opaque token; consider token theft, lifetime, audience/issuer validation, key rotation and revocation. Cookie/session authentication also requires appropriate CSRF protection for unsafe requests.
Use explicit default permissions...