-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
401 Unauthorized with oidc user. #386
Comments
Can you provide an (anonymized) example of what your kubeconfig file looks like? Thanks! |
Absolutely. Here's a kubeconfig dump, along with a redacted program. minified
program
packaging.package.json
typescript configtsconfig.json
other bits:Linux pnathan1 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64 GNU/Linux nvm use end output vs kubectl
|
Is your refresh token truly empty string ( If so, I think the problem is this line here: Which will bail before we even get to evaluating the token. This seems like a bug to me regardless, so I'll send a PR to fix, but a quick test would be for you to change the refresh token to a not-empty string and see if that fixes things. If you really have a refresh value, then I'll need to keep investigating. |
(1) Good news: I do not. It really is empty! (2) The results of the test are... Changing the refresh token to "yolo"
I validate I can then:
which is fascinating. Since I have had it for a while and kubectl uses it happily. I then remove it altogether from this specific user, and the following results:
I validate that refresh-token's presence entirely is not required for the kubectl to succeed - kubectl works along happily enough. |
So what is happening (I think) is that the javascript client tries to refresh first when there's no expiration timestamp. I think the kubectl (and Python) clients might simply try to use the token that's in the file. I think that probably trying the token makes sense so I'll update the Javascript client to use them. Also, I think the issue might be that refresh for that kubeconfig is broken. I need to dig into the OIDC client code/protocol a little more to truly understand what is the correct expectations here with regards to refresh token handling. |
Let me know if you want me to test a patch. I'm also somewhat surprised that an empty token is accepted (perhaps kubectl doesn't send empty tokens?). |
Some observations from the kubectl oidc code Extra scopes is deprecated and unused: It does require a non-zero length refresh token: But it first pulls the expired date from the the id token: The Javascript code doesn't do this last part, which is why (I think) it's not working for your client. I think I have enough information now to fix this particular issue. (and I've learned some new things about OIDC too :) |
I have a PR that I believe will fix this here: If you can patch and validate it would be much appreciated. |
Hi, Sorry about the delay. Failure in a new and improved way.
when https://github.com/swansontec/rfc4648.js/blob/master/src/codec.ts#L33 is the error. FYI: the ID token is JWT, and there's an example parser at https://jwt.io/ |
Does your JWT parse correctly in the parser at https://jwt.io? |
Can you change const payload = base64url.parse(parts[1]); to: const payload = base64url.parse(parts[1], { loose: true } as any); In the patch and see if it works? |
Yes. Hotwiring the patch in:
that works! |
ok, thanks for the confirmation. I will update my PR with that change. |
Hi,
I'm getting a consistent 403 forbidden. This doesn't happen with the Python library or kubectl. The user is an oidc user, backed by Auth0. I have ensured that the token is valid.
I can't see any particular place where I need to pass in or set a flag. The cluster is a kops-generated cluster with its own generated certificate.
Looking at https://github.com/kubernetes-client/javascript/blob/master/src/oidc_auth.ts#L43 , I see that I have a flag in my config file
extra-scopes: openid profile
, which doesn't appear to be an option in the dict there. But this doesn't seem to matter in the Python library - https://github.com/kubernetes-client/python-base/blob/6b6546131217a2a9fdcf431a286c346619d2923a/config/kube_config.py#L289First, the package.json:
And for an example function:
I'm somewhat stumped here, I'm afraid.
The text was updated successfully, but these errors were encountered: