diff --git a/app-config.yaml b/app-config.yaml index 6ca9356053..514ba8e3c7 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -48,15 +48,9 @@ auth: clientSecret: $secret: env: AUTH_GITHUB_CLIENT_SECRET - authorizationURL: + enterpriseInstanceURL: $secret: - env: AUTH_GITHUB_AUTHORIZATION_URL - tokenURL: - $secret: - env: AUTH_GITHUB_TOKEN_URL - userProfileUrl: - $secret: - env: AUTH_GITHUB_USER_PROFILE_URL + 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 7b52da4ad0..f413d56fbd 100644 --- a/plugins/auth-backend/README.md +++ b/plugins/auth-backend/README.md @@ -37,9 +37,7 @@ for github enterprise: ```bash export AUTH_GITHUB_CLIENT_ID=x export AUTH_GITHUB_CLIENT_SECRET=x -export AUTH_GITHUB_AUTHORIZATION_URL=https://ENTERPRISE_INSTANCE_URL/login/oauth/authorize -export AUTH_GITHUB_TOKEN_URL=https://ENTERPRISE_INSTANCE_URL/login/oauth/access_token -export AUTH_GITHUB_USER_PROFILE_URL=https://ENTERPRISE_INSTANCE_URL/api/v3/user +export AUTH_GITHUB_ENTERPRISE_INSTANCE_URL=https://x ``` ### Gitlab diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index 2404bd0be1..ab102bad19 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -136,9 +136,18 @@ export function createGithubProvider( const appOrigin = envConfig.getString('appOrigin'); const clientID = envConfig.getString('clientId'); const clientSecret = envConfig.getString('clientSecret'); - const authorizationURL = envConfig.getOptionalString('authorizationURL'); - const tokenURL = envConfig.getOptionalString('tokenURL'); - const userProfileURL = envConfig.getOptionalString('userProfileURL'); + 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 = {