From 768dc7d84c5ed3f2be021bf37bfc0c6583534f08 Mon Sep 17 00:00:00 2001 From: Robi Nino Date: Mon, 5 Aug 2024 09:38:37 +0300 Subject: [PATCH] Support OIDC for projects (#179) --- lib/utils.js | 4 +++- src/utils.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index ad1bca7d3..27a08a7fa 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -123,12 +123,14 @@ class Utils { // If we've reached this stage, the jfrogCredentials.jfrogUrl field should hold a non-empty value obtained from process.env.JF_URL const exchangeUrl = jfrogCredentials.jfrogUrl.replace(/\/$/, '') + '/access/api/v1/oidc/token'; core.debug('Exchanging GitHub JSON web token with a JFrog access token...'); + let projectKey = process.env.JF_PROJECT || ''; const httpClient = new http_client_1.HttpClient(); const data = `{ "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", "subject_token_type": "urn:ietf:params:oauth:token-type:id_token", "subject_token": "${jsonWebToken}", - "provider_name": "${oidcProviderName}" + "provider_name": "${oidcProviderName}", + "project_key": "${projectKey}" }`; const additionalHeaders = { 'Content-Type': 'application/json', diff --git a/src/utils.ts b/src/utils.ts index 0c540f705..2d1bb05df 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -134,12 +134,15 @@ export class Utils { const exchangeUrl: string = jfrogCredentials.jfrogUrl!.replace(/\/$/, '') + '/access/api/v1/oidc/token'; core.debug('Exchanging GitHub JSON web token with a JFrog access token...'); + let projectKey: string = process.env.JF_PROJECT || ''; + const httpClient: HttpClient = new HttpClient(); const data: string = `{ "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", "subject_token_type": "urn:ietf:params:oauth:token-type:id_token", "subject_token": "${jsonWebToken}", - "provider_name": "${oidcProviderName}" + "provider_name": "${oidcProviderName}", + "project_key": "${projectKey}" }`; const additionalHeaders: OutgoingHttpHeaders = {