diff --git a/.gitignore b/.gitignore index 57d9462..dd5d1a0 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,5 @@ out .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +.vscode \ No newline at end of file diff --git a/README.md b/README.md index 7821d62..40f527f 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,10 @@ steps: * `api` * Url of the cloud controller api * required -* `client_assertion` - * jwt for usage with `private_key_jwt` +* `audience` + * audience for requesting the Github `id_token` used for JWT Bearer Token Grant + * required + * default: `uaa` * `client_id` * client id for `client_credentals` or `jwt-bearer` * `client_secret` @@ -51,8 +53,8 @@ steps: * `client_credentals` * `private_key_jwt` * `jwt-bearer` -* `id_token` - * id_token to be used for `jwt-bearer`, if not specified a Github id_token will be requested +* `jwt` + * jwt for usage with `private_key_jwt` or `jwt-bearer`. If none is specified for `jwt-bearer`, a Github `id_token` will be requested * `username` * username for `password` grant * `password` @@ -65,10 +67,6 @@ steps: * cf cli version * required * default: `8.7.10` -* `audience` - * audience for requesting the id_token used for JWT Bearer Token Grant - * required - * default: `uaa` ## Advanced diff --git a/action.yaml b/action.yaml index 5167cce..a8d7e81 100644 --- a/action.yaml +++ b/action.yaml @@ -12,9 +12,6 @@ inputs: description: "github id_token audience" required: false default: "uaa" - client_assertion: - description: "client assertion for requesting token" - required: true client_id: description: "client id" required: false @@ -28,8 +25,8 @@ inputs: description: "grant type for requesting token" required: true default: "password" - id_token: - description: "id_token for JWT Bearer Token Grant" + jwt: + description: "jwt for usage with `private_key_jwt` or `jwt-bearer`." required: false username: description: "username" diff --git a/dist/index.js b/dist/index.js index e775488..a5864e1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -28879,11 +28879,10 @@ function run() { try { let api = core.getInput("api", { required: true }); let grant_type = core.getInput("grant_type", { required: true }); - let client_assertion = core.getInput("client_assertion"); let client_id = core.getInput("client_id"); let client_secret = core.getInput("client_secret"); let command = core.getInput("command"); - let id_token = core.getInput("id_token"); + let jwt = core.getInput("jwt"); let username = core.getInput("username"); let password = core.getInput("password"); let org = core.getInput("org"); @@ -28898,22 +28897,22 @@ function run() { if (!audience || !client_id || !client_secret) { throw new Error(`>>> For JWT Bearer Token Grant audience, client_id and client_secret need to be provided`); } - if (!id_token) { - id_token = yield request_github_idToken(audience); - core.info(">>> Successfully requested github id_token"); + if (!jwt) { + jwt = yield request_github_idToken(audience); + core.info(">>> Successfully requested github id token"); } let uaaEndpoint = JSON.parse(fs.readFileSync(cf_config)).UaaEndpoint; - let token = yield request_token_jwt_bearer(uaaEndpoint, client_id, client_secret, id_token); + let token = yield request_token_jwt_bearer(uaaEndpoint, client_id, client_secret, jwt); core.info(">>> Successfully requested uaa token using JWT Bearer Token Grant"); yield update_cf_token(token); core.info(">>> Successfully updated token in cf config"); } else if (grant_type == "private_key_jwt") { - if (!client_assertion) { - throw new Error(`>>> For Client Credentials Grant using private_key_jwt, client_assertion needs to be provided`); + if (!jwt) { + throw new Error(`>>> For Client Credentials Grant using private_key_jwt, jwt needs to be provided`); } let uaaEndpoint = JSON.parse(fs.readFileSync(cf_config)).UaaEndpoint; - let token = yield request_token_jwt(uaaEndpoint, client_assertion); + let token = yield request_token_jwt(uaaEndpoint, jwt); core.info(">>> Successfully requested uaa token using Client Credentials Grant with private_key_jwt"); yield update_cf_token(token); core.info(">>> Successfully updated token in cf config"); diff --git a/src/index.ts b/src/index.ts index 50523ce..55ad652 100755 --- a/src/index.ts +++ b/src/index.ts @@ -95,11 +95,10 @@ async function run() { try { let api = core.getInput("api", { required: true }); let grant_type = core.getInput("grant_type", { required: true }); - let client_assertion = core.getInput("client_assertion"); let client_id = core.getInput("client_id"); let client_secret = core.getInput("client_secret"); let command = core.getInput("command"); - let id_token = core.getInput("id_token"); + let jwt = core.getInput("jwt"); let username = core.getInput("username"); let password = core.getInput("password"); let org = core.getInput("org"); @@ -117,16 +116,16 @@ async function run() { `>>> For JWT Bearer Token Grant audience, client_id and client_secret need to be provided`, ); } - if (!id_token) { - id_token = await request_github_idToken(audience); - core.info(">>> Successfully requested github id_token"); + if (!jwt) { + jwt = await request_github_idToken(audience); + core.info(">>> Successfully requested github id token"); } let uaaEndpoint = JSON.parse(fs.readFileSync(cf_config)).UaaEndpoint; let token = await request_token_jwt_bearer( uaaEndpoint, client_id, client_secret, - id_token, + jwt, ); core.info( ">>> Successfully requested uaa token using JWT Bearer Token Grant", @@ -134,13 +133,13 @@ async function run() { await update_cf_token(token); core.info(">>> Successfully updated token in cf config"); } else if (grant_type == "private_key_jwt") { - if (!client_assertion) { + if (!jwt) { throw new Error( - `>>> For Client Credentials Grant using private_key_jwt, client_assertion needs to be provided`, + `>>> For Client Credentials Grant using private_key_jwt, jwt needs to be provided`, ); } let uaaEndpoint = JSON.parse(fs.readFileSync(cf_config)).UaaEndpoint; - let token = await request_token_jwt(uaaEndpoint, client_assertion); + let token = await request_token_jwt(uaaEndpoint, jwt); core.info( ">>> Successfully requested uaa token using Client Credentials Grant with private_key_jwt", );