Skip to content

Commit

Permalink
Unable to authenticate using Github Enterprise (#6644)
Browse files Browse the repository at this point in the history
Fixes #6426
  • Loading branch information
alexr00 authored Feb 7, 2025
1 parent c506da9 commit 25e3680
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@
},
{
"view": "github:login",
"when": "ReposManagerStateContext == NeedsAuthentication && !github:hasGitHubRemotes && gitOpenRepositoryCount",
"when": "(ReposManagerStateContext == NeedsAuthentication) && ((!github:hasGitHubRemotes && gitOpenRepositoryCount) || config.github-enterprise.uri)",
"contents": "%welcome.github.loginWithEnterprise.contents%"
},
{
Expand Down
13 changes: 12 additions & 1 deletion src/github/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AuthProvider } from '../common/authentication';
import { Disposable } from '../common/lifecycle';
import Logger from '../common/logger';
import * as PersistentState from '../common/persistentState';
import { GITHUB_ENTERPRISE, URI } from '../common/settingKeys';
import { ITelemetry } from '../common/telemetry';
import { agent } from '../env/node/net';
import { IAccount } from './interface';
Expand Down Expand Up @@ -213,8 +214,18 @@ export class CredentialStore extends Disposable {
private async doCreate(options: vscode.AuthenticationGetSessionOptions, additionalScopes: boolean = false): Promise<AuthResult> {
const github = await this.initialize(AuthProvider.github, options, additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined, additionalScopes);
let enterprise: AuthResult | undefined;
const initializeEnterprise = () => this.initialize(AuthProvider.githubEnterprise, options, additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined, additionalScopes);
if (hasEnterpriseUri()) {
enterprise = await this.initialize(AuthProvider.githubEnterprise, options, additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined, additionalScopes);
enterprise = await initializeEnterprise();
} else {
// Listen for changes to the enterprise URI and try again if it changes.
const disposable = vscode.workspace.onDidChangeConfiguration(async e => {
if (e.affectsConfiguration(`${GITHUB_ENTERPRISE}.${URI}`) && hasEnterpriseUri()) {
enterprise = await initializeEnterprise();
disposable.dispose();
}
});
this.context.subscriptions.push(disposable);
}
return {
canceled: github.canceled || !!(enterprise && enterprise.canceled)
Expand Down

0 comments on commit 25e3680

Please sign in to comment.