Auth0 kan worden gebruikt als een OpenID Connect-provider voor LibreChat. Wanneer je Auth0 gebruikt met token-hergebruik ingeschakeld (OPENID_REUSE_TOKENS=true), moet je de omgevingsvariabele OPENID_AUDIENCE configureren om authenticatieproblemen te voorkomen.
Auth0 staat geen http://localhost URL's toe in productieapplicaties. Voor lokale ontwikkeling/testen moet je HTTPS gebruiken. Je kunt gebruikmaken van diensten zoals:
ngrok: ngrok http 3080 (biedt een HTTPS-tunnel naar localhost)
Caddy: Lokale HTTPS-proxyserver
localtunnel: Vergelijkbaar met ngrok
Voorbeeld met ngrok:
ngrok http 3080# This will give you a URL like: https://abc123.ngrok.io
Deze stap is vereist bij het gebruik van OPENID_REUSE_TOKENS=true. Zonder deze stap zal Auth0 ondoorzichtige tokens retourneren die niet door LibreChat kunnen worden gevalideerd, wat leidt tot oneindige vernieuwingslussen.
Voeg de volgende omgevingsvariabelen toe aan je .env bestand:
# OpenID Connect Configuration# Domain from Basic Information (add https:// prefix)OPENID_ISSUER=https://dev-abc123.us.auth0.com# Client ID from Basic InformationOPENID_CLIENT_ID=your_long_alphanumeric_client_id# Client Secret from Basic Information (click to reveal)OPENID_CLIENT_SECRET=your_client_secret_from_basic_information# Callback URL (must match what's configured in Auth0)OPENID_CALLBACK_URL=/oauth/openid/callback# Token ConfigurationOPENID_REUSE_TOKENS=trueOPENID_SCOPE=openid profile email offline_access# IMPORTANT: Your Auth0 API identifier (from Step 3)OPENID_AUDIENCE=https://api.librechat.ai# Security Settings (recommended)OPENID_USE_PKCE=true# Session Configuration (generate a secure random string)OPENID_SESSION_SECRET=your-secure-session-secret-32-chars-or-more# Maximum logout URL length before using logout_hint instead of id_token_hint (default: 2000)# OPENID_MAX_LOGOUT_URL_LENGTH=2000# Optional: Custom button appearanceOPENID_BUTTON_LABEL=Continue with Auth0# OPENID_IMAGE_URL=https://path-to-auth0-logo.png# If using ngrok for testing, also update:# DOMAIN_CLIENT=https://your-domain.ngrok.io# DOMAIN_SERVER=https://your-domain.ngrok.io
LibreChat bevat de audience parameter in autorisatieverzoeken, waarbij de eerste niet-lege waarde wordt gebruikt wanneer er meerdere door komma's gescheiden audiences zijn geconfigureerd.
Auth0 herkent de audience als een geregistreerde API
Auth0 geeft JWT-toegangstokens uit die gevalideerd kunnen worden
LibreChat valideert tokens succesvol en authenticatie werkt naar behoren
De identifier van uw Auth0 API. Vereist bij gebruik van OPENID_REUSE_TOKENS=true met Auth0 om problemen met opaque tokens te voorkomen. Door komma's gescheiden waarden worden geaccepteerd voor JWT-validatie; autorisatieverzoeken gebruiken de eerste niet-lege waarde.