Configuring Authelia Authentication Service
NextAuth (Auth.js) has been fully removed from LobeHub. The NEXT_AUTH_SSO_PROVIDERS and AUTH_URL variables shown below will now cause the deployment to fail at build/startup. This page is kept for historical reference only — use the Better Auth provider guides and the NextAuth to Better Auth migration guide instead.
Authelia Configuration Flow
Create an Authelia Identity Provider
We assume you are already familiar with using Authelia. Let's say your LobeHub instance is deployed at https://lobe.example.com/. Note that currently only localhost supports HTTP access; other domains need to enable TLS, otherwise Authelia will actively interrupt authentication by default.
Now, let's open and edit the configuration file of your Authelia instance:
Add a new lobehub item under identity_providers -> oidc:
Make sure to replace secret and redirect_urls with your own values. Note! The secret configured in Authelia is ciphertext, i.e., a salted hash value. Its corresponding plaintext needs to be filled in LobeHub later.
Save the configuration file and restart the Authelia service. Now we have completed the Authelia configuration.
Configure Environment Variables
When deploying LobeHub, you need to configure the following environment variables:
| Environment Variable | Type | Description |
|---|---|---|
AUTH_SECRET | Required | The secret used to encrypt Auth.js session tokens. You can generate a secret using the following command: openssl rand -base64 32 |
NEXT_AUTH_SSO_PROVIDERS | Required | Select the SSO provider for LoboChat. Use authentik for Authentik. |
AUTH_AUTHELIA_ID | Required | The id just configured in Authelia, example value is lobehub |
AUTH_AUTHELIA_SECRET | Required | The plaintext corresponding to the secret just configured in Authelia, example value is insecure_secret |
AUTH_AUTHELIA_ISSUER | Required | Your Authelia URL, for example https://sso.example.com |
AUTH_URL | Required | This URL is used to specify the callback address for Auth.js when performing OAuth verification. It only needs to be set when the default generated redirect address is incorrect. https://chat.example.com/api/auth |
Go to 📘 Environment Variables for details about the variables.
After a successful deployment, users will be able to use LobeHub by authenticating with the users configured in Authelia.