Merge pull request #30136 from elaine-mattos/fix/oauth-vs-integration-token-merge
fix: prevent oauth and integration token merge
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/backend-defaults': patch
|
||||
'@backstage/integration': patch
|
||||
---
|
||||
|
||||
Fixed bug where the GitLab user token and GitLab integration token were being merged together
|
||||
@@ -340,10 +340,7 @@ export class GitlabUrlReader implements UrlReaderService {
|
||||
);
|
||||
}
|
||||
// Default to the old behavior of assuming the url is for a file
|
||||
return getGitLabFileFetchUrl(target, {
|
||||
...this.integration.config,
|
||||
...(token && { token }),
|
||||
});
|
||||
return getGitLabFileFetchUrl(target, this.integration.config, token);
|
||||
}
|
||||
|
||||
// convert urls of the form:
|
||||
|
||||
@@ -588,6 +588,7 @@ export function getGitilesAuthenticationUrl(
|
||||
export function getGitLabFileFetchUrl(
|
||||
url: string,
|
||||
config: GitLabIntegrationConfig,
|
||||
token?: string,
|
||||
): Promise<string>;
|
||||
|
||||
// @public
|
||||
|
||||
@@ -40,8 +40,9 @@ import {
|
||||
export async function getGitLabFileFetchUrl(
|
||||
url: string,
|
||||
config: GitLabIntegrationConfig,
|
||||
token?: string,
|
||||
): Promise<string> {
|
||||
const projectID = await getProjectId(url, config);
|
||||
const projectID = await getProjectId(url, config, token);
|
||||
return buildProjectUrl(url, projectID, config).toString();
|
||||
}
|
||||
|
||||
@@ -113,6 +114,7 @@ export function buildProjectUrl(
|
||||
export async function getProjectId(
|
||||
target: string,
|
||||
config: GitLabIntegrationConfig,
|
||||
token?: string,
|
||||
): Promise<number> {
|
||||
const url = new URL(target);
|
||||
|
||||
@@ -143,7 +145,7 @@ export async function getProjectId(
|
||||
|
||||
const response = await fetch(
|
||||
repoIDLookup.toString(),
|
||||
getGitLabRequestOptions(config),
|
||||
getGitLabRequestOptions(config, token),
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user