Django Authentication & Security Flashcards
6 cards from real Django practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Django Authentication & Security flashcards as text
What does the `X-Frame-Options: DENY` header configured via Django's `XFrameOptionsMiddleware` prevent?
Answer: Clickjacking attacks where the site is embedded in an iframe
X-Frame-Options: DENY prevents the page from being rendered in any iframe, protecting against clickjacking where attackers overlay invisible frames to trick users.
Which Django setting enables automatic escaping of template variables to prevent XSS?
Answer: Django auto-escapes by default; no setting is needed to enable it
Django's template engine auto-escapes all variable output by default, converting dangerous characters to HTML entities without any configuration.
What is the purpose of Django's `AUTH_PASSWORD_VALIDATORS` setting?
Answer: Defines rules like minimum length and common password checks enforced on password changes
AUTH_PASSWORD_VALIDATORS is a list of validator classes that run when users set or change passwords, enforcing strength requirements.
What does setting `SESSION_COOKIE_SECURE = True` do in Django?
Answer: Restricts the session cookie to HTTPS connections only
SESSION_COOKIE_SECURE = True adds the Secure flag to the session cookie, preventing browsers from sending it over unencrypted HTTP connections.
Which Django permission method checks if a user has a specific model-level permission?
Answer: user.has_perm('app.codename')
has_perm() checks if the user has the given permission via the authentication backends and returns True or False.
What does Django's `ALLOWED_HOSTS` setting prevent?
Answer: HTTP Host header injection attacks by whitelisting valid hostnames for the site
ALLOWED_HOSTS validates the HTTP Host header against the whitelist, preventing attackers from making requests with spoofed Host headers that could cause cache poisoning.
Written and edited by Nathan Beja, founder of Practice Test Geeks, with AI assistance. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Editorial policy