Skip to content

Commit 11a63c0

Browse files
committed
force using native oidc flow
1 parent 4336997 commit 11a63c0

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/oidc-utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class OidcUtils {
3636
for further use by the users, this cannot be done in secure way using jf config add command.
3737
3838
*/
39-
public static async exchangeOidcToken(jfrogCredentials: JfrogCredentials): Promise<string | undefined> {
39+
public static async exchangeOidcToken(jfrogCredentials: JfrogCredentials, forceManual: boolean = false): Promise<string | undefined> {
4040
if (!jfrogCredentials.jfrogUrl) {
4141
throw new Error(`JF_URL must be provided when oidc-provider-name is specified`);
4242
}
@@ -49,13 +49,14 @@ export class OidcUtils {
4949
}
5050

5151
// Version should be more than min version
52-
// If CLI_REMOTE_ARG specified, we have to fetch token before we can download the CLI.
53-
if (this.isCLIVersionOidcSupported() && !core.getInput(Utils.CLI_REMOTE_ARG)) {
52+
// If forceManual is true (e.g., for CLI download from remote repo), use manual flow.
53+
// Otherwise, prefer native CLI flow if version is supported.
54+
if (this.isCLIVersionOidcSupported() && !forceManual) {
5455
core.debug('Using CLI exchange-oidc-token..');
5556
return await this.exchangeOIDCTokenAndExportStepOutputs(jfrogCredentials);
5657
}
5758

58-
// Fallback to manual OIDC exchange for backward compatibility
59+
// Fallback to manual OIDC exchange for backward compatibility or when forced
5960
core.debug('Using Manual OIDC Auth Method..');
6061
// Exchanges the token and set as access token in the credential's object
6162
let token: string | undefined = await this.manualExchangeOidc(jfrogCredentials);
@@ -304,6 +305,7 @@ export class OidcUtils {
304305

305306
public static isCLIVersionOidcSupported(): boolean {
306307
const version: string = core.getInput(Utils.CLI_VERSION_ARG) || '';
308+
core.info("SHAYS Checking if CLI version supports OIDC token exchange. Provided version: '" + version + "'");
307309
if (version === '') {
308310
// No input meaning default version which is supported
309311
return true;

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ export class Utils {
110110
return;
111111
}
112112
// To download CLI from a remote repository, we first need to fetch an access token.
113-
// This should fall back to the 'manual' oidc exchange method.
113+
// Force manual OIDC flow since CLI is not yet available.
114114
if (jfrogCredentials.oidcProviderName && cliRemote != '') {
115-
core.debug("'Fetching OIDC access token to download CLI from remote repository");
116-
jfrogCredentials.accessToken = await OidcUtils.exchangeOidcToken(jfrogCredentials);
115+
core.debug('Fetching OIDC access token to download CLI from remote repository using manual flow');
116+
jfrogCredentials.accessToken = await OidcUtils.exchangeOidcToken(jfrogCredentials, true);
117117
}
118118
// Download JFrog CLI
119119
let downloadDetails: DownloadDetails = Utils.extractDownloadDetails(cliRemote, jfrogCredentials);

0 commit comments

Comments
 (0)