Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Multi-Tenant OpenID Authentication Support #5732

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rubentalstra
Copy link
Collaborator

@rubentalstra rubentalstra commented Feb 8, 2025

🎯 Summary

Closes: #4544

This PR introduces support for multi-tenant OpenID authentication. Instead of relying on a single OpenID configuration, the system can now handle multiple tenants, each with its own client ID, client secret, and issuer. The PR also includes UI updates to accommodate multi-tenant login, backend logic refactoring, and YAML configuration updates.

🔍 Changes Overview

🔧 Configuration Updates

  • .env.example
    • Replaced OPENID_CLIENT_ID, OPENID_CLIENT_SECRET, and OPENID_ISSUER with OPENID_ENABLED.
    • Added OPENID_MULTI_TENANT support.
  • librechat.example.yaml
    • Introduced openid.tenants array for defining multiple OpenID providers.

⚙️ Backend Enhancements

  • api/server/routes/config.js
    • Updated OpenID config checks to support OPENID_ENABLED instead of requiring all individual OpenID env variables.
    • Introduced openidMultiTenantEnabled flag.
  • api/server/routes/oauth.js
    • Replaced static OpenID authentication with a dynamic strategy selection using chooseOpenIdStrategy.
  • api/server/utils/openidHelper.js (New file!)
    • Implements logic to map email domains to the correct OpenID strategy dynamically.
  • api/strategies/openidStrategy.js
    • Implements logic for dynamically registering multiple OpenID strategies from YAML configuration.

🖥️ UI & Frontend Updates

  • client/src/components/Auth/MultiTenantOpenID.tsx (New file!)
    • Introduces an OpenID login form where users input their email, allowing domain-based strategy selection.
  • client/src/components/Auth/SocialLoginRender.tsx
    • Renders Multi-Tenant OpenID UI when openidMultiTenantEnabled is true.
  • packages/data-provider/src/config.ts
    • Updated TStartupConfig schema to include openidMultiTenantEnabled.

Single-tenant

Screenshot 2025-02-08 at 13 08 17

Multi-tenant

Screenshot 2025-02-08 at 13 08 46

✅ TODO

  • Code refactoring and cleanup.
  • Additional testing for multiple tenants.
  • Documentation updates.

🧪 Testing

Test Configuration:

  • Enabled OPENID_MULTI_TENANT=true.
  • Added multiple OpenID tenants in librechat.example.yaml.
  • Tested login with different email domains.

📋 Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes
  • A pull request for updating the documentation has been submitted.

TODO:
working code but needs some refactoring and cleaning up.
@rubentalstra rubentalstra linked an issue Feb 8, 2025 that may be closed by this pull request
1 task
@rubentalstra rubentalstra self-assigned this Feb 8, 2025
@rubentalstra rubentalstra added the ✨ enhancement New feature or request label Feb 8, 2025
@rubentalstra rubentalstra changed the title 🚀 Multi-Tenant OpenID Authentication Support WIP: 🚀 Multi-Tenant OpenID Authentication Support Feb 9, 2025
@rubentalstra rubentalstra changed the title WIP: 🚀 Multi-Tenant OpenID Authentication Support WIP: Multi-Tenant OpenID Authentication Support Feb 9, 2025
Repository owner deleted a comment from github-actions bot Feb 12, 2025
@rubentalstra
Copy link
Collaborator Author

rubentalstra commented Feb 12, 2025

I’m not really sure myself. This might be useful, but I think it’s out of scope for this project.

@danny-avila ^ what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Multitenant OpenID Login with Home Zone Discovery
1 participant