Skip to content

Commit e75d76a

Browse files
committed
Uses protocol that is specified on GK-cloud for Bitbucket Server
(#4107, #4146)
1 parent 710bb01 commit e75d76a

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

src/plus/integrations/authentication/configuredIntegrationService.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface StoredSession {
2323
cloud?: boolean;
2424
expiresAt?: string;
2525
domain?: string;
26+
protocol?: string;
2627
}
2728

2829
export type ConfiguredIntegrationType = 'cloud' | 'local';
@@ -396,5 +397,6 @@ function convertStoredSessionToSession(
396397
cloud: storedSession.cloud ?? cloudIfMissing,
397398
expiresAt: storedSession.expiresAt ? new Date(storedSession.expiresAt) : undefined,
398399
domain: storedSession.domain ?? descriptor.domain,
400+
protocol: storedSession.protocol,
399401
};
400402
}

src/plus/integrations/authentication/integrationAuthenticationProvider.ts

+3
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ export abstract class CloudIntegrationAuthenticationProvider<
274274

275275
if (!session) return undefined;
276276

277+
const sessionProtocol = new URL(session.domain).protocol;
278+
277279
// TODO: Once we care about domains, we should try to match the domain here against ours, and if it fails, return undefined
278280
return {
279281
id: this.configuredIntegrationService.getSessionId(descriptor),
@@ -287,6 +289,7 @@ export abstract class CloudIntegrationAuthenticationProvider<
287289
expiresAt: new Date(session.expiresIn * 1000 + Date.now()),
288290
// Note: do not use the session's domain, because the format is different than in our model
289291
domain: descriptor.domain,
292+
protocol: sessionProtocol ?? undefined,
290293
};
291294
}
292295

src/plus/integrations/authentication/models.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ProviderAuthenticationSession extends AuthenticationSession {
1313
readonly cloud: boolean;
1414
readonly expiresAt?: Date;
1515
readonly domain: string;
16+
readonly protocol?: string;
1617
}
1718

1819
export interface ConfiguredIntegrationDescriptor {

src/plus/integrations/providers/bitbucket-server.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export class BitbucketServerIntegration extends HostingIntegration<
4343
}
4444

4545
protected get apiBaseUrl(): string {
46-
return `https://${this.domain}/rest/api/1.0`;
46+
const protocol = this._session?.protocol ?? 'https:';
47+
return `${protocol}//${this.domain}/rest/api/1.0`;
4748
}
4849

4950
protected override async mergeProviderPullRequest(

0 commit comments

Comments
 (0)