diff --git a/lib/utils.js b/lib/utils.js index b13b3af67..0356c1588 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -81,13 +81,16 @@ class Utils { if (!isLatestVer && (0, semver_1.lt)(version, this.MIN_CLI_VERSION)) { throw new Error('Requested to download JFrog CLI version ' + version + ' but must be at least ' + this.MIN_CLI_VERSION); } - if (jfrogCredentials.oidcProviderName && cliRemote != '') { - throw new Error('OIDC credentials are not supported for CLI remote downloads, please use an access token instead.'); - } if (!isLatestVer && this.loadFromCache(version)) { core.info('Found JFrog CLI in cache. No need to download'); return; } + // To download CLI from a remote repository, we first need to fetch an access token. + // This should fall back to the 'manual' oidc exchange method. + if (jfrogCredentials.oidcProviderName && cliRemote != '') { + core.debug("'Fetching OIDC access token to download CLI from remote repository"); + jfrogCredentials.accessToken = yield oidc_utils_1.OidcUtils.exchangeOidcToken(jfrogCredentials); + } // Download JFrog CLI let downloadDetails = Utils.extractDownloadDetails(cliRemote, jfrogCredentials); let url = Utils.getCliUrl(version, Utils.getJFrogExecutableName(), downloadDetails); diff --git a/src/utils.ts b/src/utils.ts index 5e045cd96..32de63c85 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -95,13 +95,16 @@ export class Utils { if (!isLatestVer && lt(version, this.MIN_CLI_VERSION)) { throw new Error('Requested to download JFrog CLI version ' + version + ' but must be at least ' + this.MIN_CLI_VERSION); } - if (jfrogCredentials.oidcProviderName && cliRemote != '') { - throw new Error('OIDC credentials are not supported for CLI remote downloads, please use an access token instead.'); - } if (!isLatestVer && this.loadFromCache(version)) { core.info('Found JFrog CLI in cache. No need to download'); return; } + // To download CLI from a remote repository, we first need to fetch an access token. + // This should fall back to the 'manual' oidc exchange method. + if (jfrogCredentials.oidcProviderName && cliRemote != '') { + core.debug("'Fetching OIDC access token to download CLI from remote repository"); + jfrogCredentials.accessToken = await OidcUtils.exchangeOidcToken(jfrogCredentials); + } // Download JFrog CLI let downloadDetails: DownloadDetails = Utils.extractDownloadDetails(cliRemote, jfrogCredentials); let url: string = Utils.getCliUrl(version, Utils.getJFrogExecutableName(), downloadDetails);