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

🔑feat: SAML authentication #6169

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

tsutsu3
Copy link

@tsutsu3 tsutsu3 commented Mar 4, 2025

Pull Request Template

⚠️ Before Submitting a PR, Please Review:

  • Please ensure that you have thoroughly read and understood the Contributing Docs before submitting your Pull Request.

⚠️ Documentation Updates Notice:

  • Kindly note that documentation updates are managed in this repository: librechat.ai

Summary

saml

ref: #6034

Many organizations use SAML for single sign-on (SSO) authentication.
Adding SAML login support allows seamless integration with enterprise authentication systems, improving security and user convenience.

Dependencies:

  • node-saml/passport-saml
  • passport-saml-metadata
  • xml2js

Key Points

  • Implemented SAML authentication using a issuer, entry_point, cert.
  • Single Logout (SLO) is not supported.
  • Disabling SAML registration from the LibreChat UI is not supported.
  • SAML_CERT supports both a cert file path and a cert string.
  • SAML is disabled if OpenID is enabled (mutually exclusive authentication methods).
  • Support Signed SAML Response and Signed SAML Assertion.

Concerns

  • SAML icon and its license.
  • How to register the com_auth_saml_login key in Locize. (not yet)

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Translation update

Testing

Test Configuration:

See: LibreChat-AI/librechat.ai#255

Setup Auth0 SAML and .env.

Checklist

Please delete any irrelevant options.

  • 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
  • Any changes dependent on mine have been merged and published in downstream modules.
  • A pull request for updating the documentation has been submitted.

@rubentalstra rubentalstra added this to the v0.7.8 milestone Mar 4, 2025
@rubentalstra rubentalstra added the ✨ enhancement New feature or request label Mar 4, 2025
@rubentalstra rubentalstra self-assigned this Mar 4, 2025
@tsutsu3 tsutsu3 marked this pull request as ready for review March 4, 2025 13:01
Copy link
Collaborator

@rubentalstra rubentalstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please have a look at my comment at:
docker-compose.override.yml.example

Comment on lines 56 to 61
# # ADD SAML METADATA FILE
# api:
# - type: bind
# source: ./your-metadata.xml
# target: /app/your-metadata.xml

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed here something? you mean the cert file here right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you still made a typo 😅 ycert.pem

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to your_cert.pem

Comment on lines +62 to +71
!!process.env.APPLE_CLIENT_ID &&
!!process.env.APPLE_TEAM_ID &&
!!process.env.APPLE_KEY_ID &&
!!process.env.APPLE_PRIVATE_KEY_PATH,
openidLoginEnabled: isOpenIdEnabled,
openidLabel: process.env.OPENID_BUTTON_LABEL || 'Continue with OpenID',
openidImageUrl: process.env.OPENID_IMAGE_URL,
samlLoginEnabled: !isOpenIdEnabled && isSamlEnabled,
samlLabel: process.env.SAML_BUTTON_LABEL,
samlImageUrl: process.env.SAML_IMAGE_URL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this file. about this logic in specific:

samlLoginEnabled: !isOpenIdEnabled && isSamlEnabled,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is designed to ensure that only one authentication method, either OpenID or SAML, can be enabled at a time.

I thought the comment no that you can only setup OpenID or SAML also in the backend api suggested that OpenID and SAML should be mutually exclusive.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're correct. It's not common to allow SAML and OpenID authentication at the same time.

But it's more about the changes you made in that file that I'm not fully sure about that's all. I just need to have a good look. 👀

@tsutsu3
Copy link
Author

tsutsu3 commented Mar 5, 2025

Testing with different combinations of app session, IdP session, and SAML token expiration...

Especially curious about the behavior when the IdP session expires while the app session remains active—want to align it with OpenID behavior.


result:

Same behavior as OpenID:

Reauthentication is required only if both the app session has expired (or the user has logged out) and the IdP session is also expired.

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.

2 participants