Dynamic secret admin URL for Django
Time-based. Deterministic. No storage.
django-smart-dynamic-path — dynamic secret admin URL for Django. Hide your Django admin behind a URL that changes daily/monthly. Only you know the secret phrase to generate the current path.
Standard Django admin: /admin/ (always the same)
This package: /admin/a1b2c3d4e5f6g7h8/ (changes automatically)
{% secret_admin_link %}get_admin_path(), get_admin_url()pip install django-smart-dynamic-path
1. Add to INSTALLED_APPS
INSTALLED_APPS = [
'django_smart_dynamic_path',
'django.contrib.admin',
# ...
]
2. Replace admin URLs in urls.py
from django.urls import path, include
urlpatterns = [
path('admin/', include('django_smart_dynamic_path.urls')),
]
3. Generate SECRET_KEY from secret phrase (local)
smart-dynamic-path --secret "your secret phrase" --key-only
Copy the output and set as SECRET_KEY in your .env or settings.py.
4. Configure period (optional, in settings.py)
SECRET_ADMIN_PERIOD = 'day' # day, month, static
5. Get current admin path (server)
python manage.py get_admin_path --full
Due to Django's URL compilation mechanism, the admin path is calculated once when the server starts. To apply a new path when the period changes (e.g., next day), you need to restart the server.
Automatic restart with cron:
# Add to crontab (restart at midnight) 0 0 * * * systemctl restart gunicorn
This is not a bug, but a Django architectural feature.
| Command | Output |
|---|---|
python manage.py generate_secret_key --secret "phrase" | SECRET_KEY and period |
python manage.py get_admin_path | a1b2c3d4e5f6g7h8 |
python manage.py get_admin_path --full | /a1b2c3d4e5f6g7h8/ |
{% load admin_link %}
<a href="{% secret_admin_link %}">Secret Admin</a>
from django_smart_dynamic_path import get_admin_path, get_admin_url path = get_admin_path() # 'a1b2c3d4e5f6g7h8' url = get_admin_url() # 'admin/a1b2c3d4e5f6g7h8/'
SECRET_KEY = SHA256(secret_phrase) # 64 hex chars (256 bits) ADMIN_PATH = SHA256(SECRET_KEY + date)[:16].hex() # 32 hex chars (128 bits)
git clone https://github.com/smartlegionlab/smart-dynamic-path cd smart-dynamic-path python3 -m smart_dynamic_path.cli --secret "my secret phrase" python3 -m smart_dynamic_path.cli --secret "my secret phrase" --period month --prefix admin --full python3 -m smart_dynamic_path.cli --secret "my secret phrase" --key-only
1. Pointer-Based Security
The admin URL is not stored anywhere. It is regenerated on demand from a secret phrase and current time. There is no stored "pointer" — only the ability to compute it.
2. Local Data Regeneration
The exact admin path is computed locally on the developer's machine using only the secret phrase and date, without accessing the server. The server never knows the secret phrase.
3. Position-Candidate-Hypothesis (PCH)
Among all possible URL paths (2¹²⁸ candidates), only one specific path generated by the secret phrase is valid at any given time. The hypothesis (which path is valid) is verified through the hash function.
By using this software, you agree to the full disclaimer terms.
Software provided "AS IS" without warranty. You assume all risks.
Full legal disclaimer: See DISCLAIMER.md
License: BSD 3-Clause License