Bird
0
0

You want to ensure your Django site uses HTTPS and prevents clickjacking attacks. Which combination of settings should you configure?

hard📝 Application Q15 of 15
Django - Security Best Practices
You want to ensure your Django site uses HTTPS and prevents clickjacking attacks. Which combination of settings should you configure?
AUse raw SQL queries and set SECURE_HSTS_SECONDS = 0.
BSet DEBUG = true and add 'django.middleware.security.SecurityMiddleware' to MIDDLEWARE.
CSet ALLOWED_HOSTS = ['*'] and disable CSRF protection.
DSet SECURE_SSL_REDIRECT = true and add 'django.middleware.clickjacking.XFrameOptionsMiddleware' to MIDDLEWARE.
Step-by-Step Solution
Solution:
  1. Step 1: Enable HTTPS redirection

    Setting SECURE_SSL_REDIRECT = true forces all HTTP requests to HTTPS, securing data in transit.
  2. Step 2: Prevent clickjacking

    Adding 'django.middleware.clickjacking.XFrameOptionsMiddleware' sets headers to stop the site from being framed by others.
  3. Final Answer:

    Set SECURE_SSL_REDIRECT = true and add 'django.middleware.clickjacking.XFrameOptionsMiddleware' to MIDDLEWARE. -> Option D
  4. Quick Check:

    HTTPS redirect + clickjacking middleware = secure site [OK]
Quick Trick: Use SSL redirect and clickjacking middleware for HTTPS and framing [OK]
Common Mistakes:
MISTAKES
  • Enabling DEBUG on live for security
  • Allowing all hosts without restrictions
  • Disabling CSRF protection mistakenly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes