Skip to content

Commit 512df55

Browse files
authored
Fix Remote Repository download with OIDC (#267)
1 parent 6359487 commit 512df55

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/utils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,16 @@ class Utils {
8181
if (!isLatestVer && (0, semver_1.lt)(version, this.MIN_CLI_VERSION)) {
8282
throw new Error('Requested to download JFrog CLI version ' + version + ' but must be at least ' + this.MIN_CLI_VERSION);
8383
}
84-
if (jfrogCredentials.oidcProviderName && cliRemote != '') {
85-
throw new Error('OIDC credentials are not supported for CLI remote downloads, please use an access token instead.');
86-
}
8784
if (!isLatestVer && this.loadFromCache(version)) {
8885
core.info('Found JFrog CLI in cache. No need to download');
8986
return;
9087
}
88+
// To download CLI from a remote repository, we first need to fetch an access token.
89+
// This should fall back to the 'manual' oidc exchange method.
90+
if (jfrogCredentials.oidcProviderName && cliRemote != '') {
91+
core.debug("'Fetching OIDC access token to download CLI from remote repository");
92+
jfrogCredentials.accessToken = yield oidc_utils_1.OidcUtils.exchangeOidcToken(jfrogCredentials);
93+
}
9194
// Download JFrog CLI
9295
let downloadDetails = Utils.extractDownloadDetails(cliRemote, jfrogCredentials);
9396
let url = Utils.getCliUrl(version, Utils.getJFrogExecutableName(), downloadDetails);

src/utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,16 @@ export class Utils {
9595
if (!isLatestVer && lt(version, this.MIN_CLI_VERSION)) {
9696
throw new Error('Requested to download JFrog CLI version ' + version + ' but must be at least ' + this.MIN_CLI_VERSION);
9797
}
98-
if (jfrogCredentials.oidcProviderName && cliRemote != '') {
99-
throw new Error('OIDC credentials are not supported for CLI remote downloads, please use an access token instead.');
100-
}
10198
if (!isLatestVer && this.loadFromCache(version)) {
10299
core.info('Found JFrog CLI in cache. No need to download');
103100
return;
104101
}
102+
// To download CLI from a remote repository, we first need to fetch an access token.
103+
// This should fall back to the 'manual' oidc exchange method.
104+
if (jfrogCredentials.oidcProviderName && cliRemote != '') {
105+
core.debug("'Fetching OIDC access token to download CLI from remote repository");
106+
jfrogCredentials.accessToken = await OidcUtils.exchangeOidcToken(jfrogCredentials);
107+
}
105108
// Download JFrog CLI
106109
let downloadDetails: DownloadDetails = Utils.extractDownloadDetails(cliRemote, jfrogCredentials);
107110
let url: string = Utils.getCliUrl(version, Utils.getJFrogExecutableName(), downloadDetails);

0 commit comments

Comments
 (0)