django-security

Configure Django production security settings for authentication, authorization, and request handling.

Updated Sep 13, 2025
One-click install
npx skills add https://github.com/llmh333/employee_management_spring --skill django-security-llmh333
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: django-security
Source: https://github.com/llmh333/employee_management_spring/tree/main/.gemini/skills/django-security
Command: npx skills add https://github.com/llmh333/employee_management_spring --skill django-security-llmh333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you prevent common web security vulnerabilities in Django applications by providing secure defaults and practical configuration patterns for production deployments.

Core Features & Use Cases

  • Production security settings: Configure safe headers, HTTPS-only cookie behavior, HSTS, and environment-based secret handling (e.g., DEBUG off, secure cookies, ALLOWED_HOSTS).
  • Authentication & authorization hardening: Implement a secure custom user model, strong password validation/hashers, and permission-based access control patterns (including RBAC-style roles and mixins).
  • Vulnerability prevention guidance: Apply SQL injection-safe ORM/query practices, XSS-safe template rendering and escaping rules, CSRF protection for form and AJAX flows, and secure file upload validation/hosting.
  • API and deployment safeguards: Add API authentication/permissions, rate limiting, and secure response headers like CSP and clickjacking protections while logging security events.

Quick Start

Configure your Django settings for production security, then apply the Skill’s authentication, authorization, CSRF, SQL injection, XSS, and file-upload rules to your codebase.

Frequently Asked Questions about django-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Django security settings for production?

Django security settings for production require disabling DEBUG, setting ALLOWED_HOSTS, enforcing HTTPS-only secure cookies, loading SECRET_KEY via environment variables, and applying HSTS with protective HTTP headers to prevent unauthorized access.

What is the best way to prevent SQL injection and XSS in Django applications?

Preventing SQL injection and XSS in Django involves using safe ORM query patterns to avoid raw SQL, enabling automatic template escaping for XSS prevention, and validating file uploads to block malicious content execution.

How do I set up Django authentication and role-based access control?

Django authentication and role-based access control setup requires implementing a secure custom user model, applying strong password validation hashers, and using permission-based mixins to restrict endpoint access across user roles.

Does Django CSRF protection work for API endpoints and AJAX requests?

Django CSRF protection works for API endpoints and AJAX requests by applying CSRF tokens to form submissions and asynchronous flows, while API safeguards also require rate limiting and authentication permissions to secure web requests.

Why do I need environment variables for Django secret keys?

Environment variables for Django secret keys are needed because hardcoding secrets in source code exposes them to unauthorized access, whereas environment-based secret handling keeps production credentials secure during deployment.

Can I use Django ORM to avoid SQL injection vulnerabilities?

You can use Django ORM to avoid SQL injection vulnerabilities by relying on built-in querysets instead of raw SQL, ensuring all database queries use parameterized safe ORM patterns throughout the application codebase.