Let guild members log in to the jukebox with Discord

- Optional Discord OAuth2 login (identify scope), enabled by
  DISCORD_CLIENT_SECRET, WEB_PUBLIC_URL and SESSION_SECRET; restricted to
  members of the configured guild, checked at login.
- Stateless 30-day session in a signed HttpOnly SameSite=Lax cookie; the
  OAuth state is checked against its own short-lived cookie.
- The jukebox API accepts the key or the session; with the session,
  changes must come from the site's own origin. The member's server name
  becomes the uploader name.
- GET /auth/me tells the page whether the login is enabled and who is
  logged in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-29 12:17:48 +01:00
parent 9fb54798dd
commit 399e851178
11 changed files with 489 additions and 13 deletions

View file

@ -14,3 +14,11 @@ WEB_TRUSTED_PROXIES=
NOTIFICATIONS_API_KEY=
# Facultatif : lien d'invitation temporaire publié par /invitation sans option « lien ».
INVITE_LINK=
# Facultatif : connexion avec Discord sur la page web (active si les trois sont définies).
# Secret OAuth2 de l'application (portail développeur Discord, onglet OAuth2).
DISCORD_CLIENT_SECRET=
# Adresse publique du site, sans / final (https://…). Ajouter <adresse>/auth/discord/callback
# aux « Redirects » OAuth2 de l'application.
WEB_PUBLIC_URL=
# 32 caractères au moins (openssl rand -hex 32) ; le changer déconnecte tout le monde.
SESSION_SECRET=