diff --git a/app-config.yaml b/app-config.yaml index e5f872201d..5f75ff522e 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -48,6 +48,9 @@ auth: clientSecret: $secret: env: AUTH_GITHUB_CLIENT_SECRET + enterpriseInstanceUrl: + $secret: + env: AUTH_GITHUB_ENTERPRISE_INSTANCE_URL gitlab: development: appOrigin: "http://localhost:3000/" diff --git a/plugins/auth-backend/README.md b/plugins/auth-backend/README.md index ff0b1c7a3d..f413d56fbd 100644 --- a/plugins/auth-backend/README.md +++ b/plugins/auth-backend/README.md @@ -32,6 +32,14 @@ export AUTH_GITHUB_CLIENT_ID=x export AUTH_GITHUB_CLIENT_SECRET=x ``` +for github enterprise: + +```bash +export AUTH_GITHUB_CLIENT_ID=x +export AUTH_GITHUB_CLIENT_SECRET=x +export AUTH_GITHUB_ENTERPRISE_INSTANCE_URL=https://x +``` + ### Gitlab ```bash diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index 37d661f9ab..e9c719ea1c 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -136,11 +136,26 @@ export function createGithubProvider( const appOrigin = envConfig.getString('appOrigin'); const clientID = envConfig.getString('clientId'); const clientSecret = envConfig.getString('clientSecret'); + const enterpriseInstanceUrl = envConfig.getOptionalString( + 'enterpriseInstanceUrl', + ); + const authorizationURL = enterpriseInstanceUrl + ? `${enterpriseInstanceUrl}/login/oauth/authorize` + : undefined; + const tokenURL = enterpriseInstanceUrl + ? `${enterpriseInstanceUrl}/login/oauth/access_token` + : undefined; + const userProfileURL = enterpriseInstanceUrl + ? `${enterpriseInstanceUrl}/api/v3/user` + : undefined; const callbackURL = `${baseUrl}/${providerId}/handler/frame?env=${env}`; const opts = { clientID, clientSecret, + authorizationURL, + tokenURL, + userProfileURL, callbackURL, };