Bird
0
0

How can you combine Django's clickjacking protection with a Content-Security-Policy header to maximize security?

hard📝 Application Q9 of 15
Django - Security Best Practices
How can you combine Django's clickjacking protection with a Content-Security-Policy header to maximize security?
ASet X_FRAME_OPTIONS to DENY and CSP frame-ancestors to allow all domains
BDisable XFrameOptionsMiddleware and rely only on CSP frame-ancestors
CUse only XFrameOptionsMiddleware with ALLOW-FROM for trusted domains
DKeep XFrameOptionsMiddleware enabled and add CSP frame-ancestors restricting framing to trusted domains
Step-by-Step Solution
Solution:
  1. Step 1: Understand complementary protections

    XFrameOptionsMiddleware provides basic framing protection; CSP frame-ancestors offers fine-grained control.
  2. Step 2: Combine both for stronger security

    Keep middleware enabled and add CSP header to restrict framing to trusted domains.
  3. Final Answer:

    Keep XFrameOptionsMiddleware enabled and add CSP frame-ancestors restricting framing to trusted domains -> Option D
  4. Quick Check:

    Combine middleware and CSP for best clickjacking defense [OK]
Quick Trick: Use both middleware and CSP frame-ancestors for strong protection [OK]
Common Mistakes:
MISTAKES
  • Disabling middleware unnecessarily
  • Allowing all domains in CSP frame-ancestors
  • Using unsupported ALLOW-FROM in X_FRAME_OPTIONS

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes