Add Django administration for author accounts: Auteurs group, use_editor permission, grant/revoke actions, shared login throttling

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
denis
2026-10-16 22:35:41 +02:00
parent 9496b5b054
commit 398e4487ad
23 changed files with 451 additions and 69 deletions
+17 -2
View File
@@ -9,8 +9,11 @@ INSTALLED_APPS = [
"django.contrib.contenttypes",
"django.contrib.auth",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.admin",
"sync",
"authors",
"authors.apps.AuthorsConfig",
]
MIDDLEWARE = [
@@ -20,16 +23,28 @@ MIDDLEWARE = [
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
"OPTIONS": {"context_processors": ["django.template.context_processors.request"]},
"OPTIONS": {
"context_processors": [
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
]
},
}
]
# Fichiers statiques de l'administration, servis par nginx sous /api/static/ (python manage.py collectstatic).
STATIC_URL = "/api/static/"
STATIC_ROOT = BASE_DIR / "staticfiles"
# Session des auteurs (éditeur de niveaux) : cookie HttpOnly, 8 heures.
SESSION_COOKIE_NAME = "pyquest_author"
SESSION_COOKIE_AGE = 8 * 60 * 60
+3
View File
@@ -16,3 +16,6 @@ DATABASES = {
"NAME": os.environ.get("PYQUEST_DB_PATH", BASE_DIR / "db.sqlite3"),
}
}
# Dossier des fichiers statiques collectés (essai avec nginx : scripts/local_stack.py).
STATIC_ROOT = os.environ.get("PYQUEST_STATIC_ROOT", BASE_DIR / "staticfiles")
@@ -41,3 +41,4 @@ CSRF_TRUSTED_ORIGINS = [_required("PYQUEST_ORIGIN")]
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
TRUST_REAL_IP_HEADER = True # nginx écrase X-Real-IP (voir nginx/pyquest.conf.example)
STATIC_ROOT = os.environ.get("PYQUEST_STATIC_ROOT", "/var/www/pyquest/static") # servi par nginx : /api/static/
+4
View File
@@ -1,6 +1,10 @@
from django.urls import include, path
from authors.sites import site as admin_site
urlpatterns = [
path("api/sync/", include("sync.urls")),
path("api/auth/", include("authors.urls")),
# Administration des comptes auteurs : sous /api/ pour passer par le même proxy nginx.
path("api/admin/", admin_site.urls),
]