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: added Github Enterprise SSO login #5621

Merged
merged 6 commits into from
Feb 3, 2025

Conversation

rubentalstra
Copy link
Collaborator

@rubentalstra rubentalstra commented Feb 3, 2025

Summary

Closes: #2812

Docs: LibreChat-AI/librechat.ai#217

This pull request enhances our GitHub OAuth integration by adding support for GitHub Enterprise authentication. When the environment variable GITHUB_ENTERPRISE_BASE_URL is provided, the GitHub strategy will automatically switch to using GitHub Enterprise endpoints. In addition, minor adjustments have been made to the social login registration to ensure everything integrates smoothly.

Key Changes

  • Environment Variables:
    The example configuration now includes (commented) variables for GitHub Enterprise:

    • GITHUB_ENTERPRISE_BASE_URL
    • GITHUB_ENTERPRISE_USER_AGENT
      This allows users to optionally configure GitHub Enterprise without affecting the default GitHub login behavior.
  • GitHub Strategy Update:
    In api/strategies/githubStrategy.js, the GitHub OAuth strategy now conditionally uses GitHub Enterprise endpoints if GITHUB_ENTERPRISE_BASE_URL is defined:

    • Authorization, Token, and Profile URLs: The endpoints for authorization, token exchange, user profile, and email retrieval are updated to use the enterprise base URL.
    • Custom User Agent: If GITHUB_ENTERPRISE_USER_AGENT is set, it is passed along in the request options.

Change Type

  • New feature (non-breaking change which adds functionality)

Testing

Test Configuration:

  1. Environment Setup:
    • In your .env or configuration file, enable GitHub Enterprise support by setting the following variables:
      GITHUB_ENTERPRISE_BASE_URL=https://your-ghe-instance.com
      GITHUB_ENTERPRISE_USER_AGENT=YourEnterpriseAppName
    • Leave the standard GitHub variables as they are if you also require regular GitHub authentication.

Checklist

  • My code adheres to this project's style guidelines.
  • I have performed a self-review of my code.
  • I have commented any non-obvious sections of code.
  • I have updated the example environment configuration.
  • My changes do not introduce new warnings.
  • I have written tests to cover my changes.
  • All local unit tests pass with my changes.
  • Any dependent changes in downstream modules have been merged and published.

@rubentalstra
Copy link
Collaborator Author

Going to refactor this so it would be or the normal GitHub url or a custom url.

I think this is a better strategy then adding another auth option.

@rubentalstra rubentalstra changed the title ✨ feat: added Github Enterprise SSO login WIP ✨ feat: added Github Enterprise SSO login Feb 3, 2025
@rubentalstra rubentalstra changed the title WIP ✨ feat: added Github Enterprise SSO login WIP: ✨ feat: added Github Enterprise SSO login Feb 3, 2025
@rubentalstra rubentalstra changed the title WIP: ✨ feat: added Github Enterprise SSO login ✨ feat: added Github Enterprise SSO login Feb 3, 2025
@rubentalstra
Copy link
Collaborator Author

refactoring done.

.env.example Show resolved Hide resolved
@danny-avila danny-avila merged commit 7c8a930 into danny-avila:main Feb 3, 2025
1 check passed
@rubentalstra rubentalstra deleted the feat/github-enterprise branch February 3, 2025 20:45
justinmdickey pushed a commit to e-gineering/LibreChat that referenced this pull request Feb 7, 2025
* danny-avila#2812

* refactored the code to simplify it.

* removed unneeded code

* removed unneeded code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: SSO Login for Github Enterprise
2 participants