javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Empty `client-secret` is not refreshed

Open uesyn opened this issue 4 years ago • 0 comments

Describe the bug When using OIDC for client authentication, if client-secret is empty, token refresh will fail. It is allowed for client-secret to be an empty value. It is specified in RFC6749. However, if client-secret is empty, an error occurs and the token cannot be refreshed because its value is empty. The reason for the failure is that when refreshing a token with empty client-secret, the node-openid-client client must set the token_endpoint_auth_method to none. ref: https://github.com/panva/node-openid-client/issues/402#issuecomment-916203372

error message:

TypeError: client_secret_basic client authentication method requires a client_secret
    at Client.authFor (/Users/test/src/tmp/nodejs/node_modules/openid-client/lib/helpers/client.js:124:15)
    at Client.authenticatedPost (/Users/test/src/tmp/nodejs/node_modules/openid-client/lib/helpers/client.js:163:30)
    at Client.grant (/Users/test/src/tmp/nodejs/node_modules/openid-client/lib/client.js:1336:46)
    at Client.refresh (/Users/test/src/tmp/nodejs/node_modules/openid-client/lib/client.js:1091:33)
    at OpenIDConnectAuth.refresh (/Users/test/src/tmp/nodejs/node_modules/@kubernetes/client-node/dist/oidc_auth.js:74:43)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async OpenIDConnectAuth.applyAuthentication (/Users/test/src/tmp/nodejs/node_modules/@kubernetes/client-node/dist/oidc_auth.js:46:23)
    at async KubeConfig.applyAuthorizationHeader (/Users/test/src/tmp/nodejs/node_modules/@kubernetes/client-node/dist/config.js:349:13)
    at async KubeConfig.applyOptions (/Users/test/src/tmp/nodejs/node_modules/@kubernetes/client-node/dist/config.js:357:9)
    at async KubeConfig.applyToRequest (/Users/test/src/tmp/nodejs/node_modules/@kubernetes/client-node/dist/config.js:90:9)

Client Version e.g. 0.16.3

Server Version e.g. 1.23.7

To Reproduce

  1. Prepare OIDC provider accept empty client-secret.
  2. To refresh, set the condition of this if statement to true.
  3. Run example code.

Expected behavior The refresh is successful and the token is obtained.

Example Code

import * as k8s from "@kubernetes/client-node";

async function main() {
  let client = new k8s.KubeConfig();
  client.loadFromDefault();

  let corev1 = client.makeApiClient(k8s.CoreV1Api);
  let { body: { items: nodes } } = await corev1.listNode();
  nodes.forEach((value: k8s.V1Node) => {
    console.log(value.metadata?.name);
  });
}

(async () => {
  await main();
})();

Environment (please complete the following information):

  • OS: macOS 12.3.1
  • NodeJS Version: v16.15.0

uesyn avatar Jun 19 '22 14:06 uesyn