โ† Back to Hub Getting Started Configuration SIEM Integration GitHub

Getting Started

๐Ÿ“ฆ Installation

Install Django NIS2 Shield using pip:

pip install django-nis2-shield

For development with additional tools:

pip install django-nis2-shield[dev]

Requirements: Python 3.8+ and Django 3.2, 4.x, or 5.x

โšก Quick Setup

1. Add to INSTALLED_APPS

# settings.py
INSTALLED_APPS = [
    # ...
    'django_nis2_shield',
]

2. Add Middleware

# settings.py
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    # Add after SessionMiddleware, before CommonMiddleware
    'django_nis2_shield.middleware.Nis2GuardMiddleware',
    'django.middleware.common.CommonMiddleware',
    # ...
]

3. Configure NIS2 Shield

# settings.py
from cryptography.fernet import Fernet

NIS2_SHIELD = {
    # Security Keys (CHANGE THESE IN PRODUCTION!)
    'INTEGRITY_KEY': 'your-secret-integrity-key',
    'ENCRYPTION_KEY': Fernet.generate_key(),
    
    # Privacy (GDPR)
    'ANONYMIZE_IPS': True,
    'ENCRYPT_PII': True,
    
    # Active Defense
    'ENABLE_RATE_LIMIT': True,
    'RATE_LIMIT_THRESHOLD': 100,  # requests per minute
    'ENABLE_SESSION_GUARD': True,
}

โœ… Verify Configuration

Run the built-in audit command to check your configuration:

python manage.py check_nis2

This will verify that all security settings are properly configured.

๐Ÿš€ Next Steps