[PR #3568] Extend GitHub Oauth2 strategy for use with GitHub Enterprise #4431

Open
opened 2026-03-17 01:58:13 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/3568
Author: @jabellard
Created: 11/20/2023
Status: 🔄 Open

Base: mainHead: feature/github_enterprise


📝 Commits (1)

  • 17351a4 Expose configuration settings for use with Github Enterprise

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 packages/hoppscotch-backend/src/auth/strategies/github.strategy.ts (+4 -0)

📄 Description

Description

The GitHub Oauth2 SSO strategy is built on top of the passport-github2 package. That package, by default, is configured to use public GitHub as the identity provider:
Authorization URL Setting
Token URL Setting
User Profile URL Setting
User Email URL Setting

Those defaults can be overridden so that an instance of GitHub Enterprise can be used as the identity provider.
The purpose of this PR is to enable that by setting the following environment variables:

  • GITHUB_AUTHORIZATION_URL: Authorization endpoint.
  • GITHUB_TOKEN_URL: Endpoint to retrieve access token.
  • GITHUB_USER_PROFILE_URL: Endpoint to retrieve general user info (e.g., full name).
  • GITHUB_USER_EMAIL_URL: Endpoint to retrieve user emails.

Sample configuration:

# New configuration settings================================================
GITHUB_AUTHORIZATION_URL=https://{{ENTERPRISE_INSTANCE_HOST_NAME}}/login/oauth/authorize
GITHUB_TOKEN_URL=https://{{ENTERPRISE_INSTANCE_HOST_NAME}}/login/oauth/access_token
GITHUB_USER_PROFILE_URL=https:/{{ENTERPRISE_INSTANCE_HOST_NAME}}/api/v3/user
GITHUB_USER_EMAIL_URL=https://{{ENTERPRISE_INSTANCE_HOST_NAME}}/api/v3/user/emails

# Configuration settings that remain unchanged in meaning============================= 
GITHUB_CLIENT_ID=*****************************************
GITHUB_CLIENT_SECRET=*****************************************
GITHUB_CALLBACK_URL=http://localhost:3170/v1/auth/github/callback
GITHUB_SCOPE="user:email"

The changes introduced in this PR are completed backwards compatible. As such, if if the intent is to use public GitHub as the identity provider, nothing changes. However, to use an instance of GitHub Enterprise as the identity provider, the environment variables outlined above must be set appropriately.

Checks

  • My pull request adheres to the code style of this project
  • All the tests have passed

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/3568 **Author:** [@jabellard](https://github.com/jabellard) **Created:** 11/20/2023 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feature/github_enterprise` --- ### 📝 Commits (1) - [`17351a4`](https://github.com/hoppscotch/hoppscotch/commit/17351a401060144228adc4f956ddce7367021ded) Expose configuration settings for use with Github Enterprise ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/auth/strategies/github.strategy.ts` (+4 -0) </details> ### 📄 Description ### Description The GitHub Oauth2 SSO strategy is built on top of the [passport-github2 package](https://www.npmjs.com/package/passport-github2). That package, by default, is configured to use public GitHub as the identity provider: [Authorization URL Setting](https://github.com/cfsghost/passport-github/blob/6c4e593ca4557ab841bae87378037a1379e35c26/lib/strategy.js#L53) [Token URL Setting](https://github.com/cfsghost/passport-github/blob/6c4e593ca4557ab841bae87378037a1379e35c26/lib/strategy.js#L54) [User Profile URL Setting](https://github.com/cfsghost/passport-github/blob/6c4e593ca4557ab841bae87378037a1379e35c26/lib/strategy.js#L64) [User Email URL Setting](https://github.com/cfsghost/passport-github/blob/6c4e593ca4557ab841bae87378037a1379e35c26/lib/strategy.js#L65) Those defaults can be overridden so that an instance of GitHub Enterprise can be used as the identity provider. The purpose of this PR is to enable that by setting the following environment variables: - `GITHUB_AUTHORIZATION_URL`: Authorization endpoint. - `GITHUB_TOKEN_URL`: Endpoint to retrieve access token. - `GITHUB_USER_PROFILE_URL`: Endpoint to retrieve general user info (e.g., full name). - `GITHUB_USER_EMAIL_URL`: Endpoint to retrieve user emails. Sample configuration: ```yaml # New configuration settings================================================ GITHUB_AUTHORIZATION_URL=https://{{ENTERPRISE_INSTANCE_HOST_NAME}}/login/oauth/authorize GITHUB_TOKEN_URL=https://{{ENTERPRISE_INSTANCE_HOST_NAME}}/login/oauth/access_token GITHUB_USER_PROFILE_URL=https:/{{ENTERPRISE_INSTANCE_HOST_NAME}}/api/v3/user GITHUB_USER_EMAIL_URL=https://{{ENTERPRISE_INSTANCE_HOST_NAME}}/api/v3/user/emails # Configuration settings that remain unchanged in meaning============================= GITHUB_CLIENT_ID=***************************************** GITHUB_CLIENT_SECRET=***************************************** GITHUB_CALLBACK_URL=http://localhost:3170/v1/auth/github/callback GITHUB_SCOPE="user:email" ``` The changes introduced in this PR are completed backwards compatible. As such, if if the intent is to use public GitHub as the identity provider, nothing changes. However, to use an instance of GitHub Enterprise as the identity provider, the environment variables outlined above must be set appropriately. ### Checks - [x] My pull request adheres to the code style of this project - [x] All the tests have passed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4431
No description provided.