Azure Entra
Learn how to configure LibreChat to use Azure Entra for user authentication.
- Go to the Azure Portal and sign in with your account.
- In the search box, type "Azure Entra" and click on it.
- On the left menu, click on App registrations and then on New registration.
- Give your app a name and select Web as the platform type.
- In the Redirect URI field, enter
http://localhost:3080/oauth/openid/callbackand click on Register.
- You will see an Overview page with some information about your app. Copy the Application (client) ID and the Directory (tenant) ID and save them somewhere.
- On the left menu, click on Authentication and check the boxes for Access tokens and ID tokens under Implicit grant and hybrid flows.
- On the left menu, click on Certificates & Secrets and then on New client secret. Give your secret a name and an expiration date and click on Add. You will see a Value column with your secret. Copy it and save it somewhere. Don't share it with anyone!
- If you want to restrict access by groups you should add the groups claim to the token. To do this, go to Token configuration and click on Add group claim. Select the groups you want to include in the token and click on Add.
- Open the .env file in your project folder and add the following variables with the values you copied:
- Save the .env file
Note: If using docker, run
docker compose up -dto apply the .env configuration changes
Advanced: Token Reuse
LibreChat supports reusing Azure Entra ID tokens for session management, which can provide better integration with your Azure environment. This feature allows LibreChat to use Azure's refresh tokens instead of managing its own session tokens.
To learn more about this feature and how to configure it, see Re-use OpenID Tokens for Login Session.
Advanced: Microsoft Graph API Integration
When using Azure Entra ID as your OpenID provider, you can enable Microsoft Graph API integration to enhance the permissions and sharing system with people and group search capabilities.
Prerequisites
- Your Azure app registration must have the appropriate Microsoft Graph API permissions
- Admin consent may be required for certain Graph API scopes (like
GroupMember.Read.All)
Adding Graph API Permissions
- In your Azure app registration, go to API permissions
- Click Add a permission > Microsoft Graph > Delegated permissions
- Add these permissions:
User.Read- Sign in and read user profilePeople.Read- Read user contactsGroupMember.Read.All- Read all group membershipsUser.ReadBasic.All- Read all users' basic profiles
- Click Grant admin consent if required (you'll need admin privileges)
Configuration
Required: Enable Token Reuse
Important: You MUST enable OpenID token reuse for this feature to work:
See Token Reuse Configuration above for details.
Add the following environment variables to your .env file:
When enabled, the people picker in the permissions and sharing dialogs will:
- Search both local LibreChat users and Azure Entra ID users
- Display user profiles with names and emails from your organization
- Allow searching and selecting Azure Entra ID groups
- Show group members based on your Graph API permissions
Notes
- Token reuse (
OPENID_REUSE_TOKENS=true) is mandatory for this feature to work - The
OPENID_GRAPH_SCOPESare automatically appended to your existingOPENID_SCOPEduring authentication - Group search requires the
GroupMember.Read.Allpermission, which typically needs admin consent - User search works with basic
User.Read,People.Read, andUser.ReadBasic.Allpermissions
Advanced: SharePoint Integration
LibreChat can integrate with SharePoint Online and OneDrive for Business, allowing users to browse and attach files directly from their SharePoint libraries.
Prerequisites
- All requirements from Token Reuse must be met
- Your Azure app registration needs additional SharePoint permissions
Adding SharePoint Permissions
- In your Azure app registration, go to API permissions
- Click Add a permission
For SharePoint Access:
- Select SharePoint (not Microsoft Graph)
- Choose Delegated permissions
- Add:
AllSites.Read- Read items in all site collections
For File Downloads:
-
Click Add a permission again
-
Select Microsoft Graph
-
Choose Delegated permissions
-
Add:
Files.Read.All- Read all files that user can access -
Click Grant admin consent for both permissions
Configuration
Usage
When properly configured:
- Users will see "From SharePoint" option in the file attachment menu
- Clicking it opens the native SharePoint file picker
- Users can browse and select files from any SharePoint site or OneDrive they have access to
- Selected files are downloaded and attached to the conversation
Security Note
The SharePoint integration respects all existing SharePoint permissions. Users can only access files they already have permission to view in SharePoint/OneDrive.
For detailed troubleshooting and advanced configuration, see: SharePoint Integration Guide
How is this guide?