-
Notifications
You must be signed in to change notification settings - Fork 168
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
Fixed OAuth2Authentication redirect_auth_url_handler callback not firing #445
Conversation
Remove the Bearer from x_redirect_server, with the count remove only the first coincidence and it make fails the redirect auth url callback.
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Contributor License Agreement signed and sended |
Thanks @matialm for this PR but I don't understand what you're trying to fix here. Could you please try to explain it in the description and/or ideally add a test for the issue you're trying to fix? |
Sorry for the late response, it fix the issue in this discussion: When I debug it I find it that the oauth2 redirect url callback wasn't been fired because it wasn't retriving the x_redirect_server parameter correctly. Long story short, when they were trying to remove the prefix "Bearer" from the headers because the "count=1" parameter it was removing that prefix only for the parameter x_token_server and not from x_redirect_server. Removing "count=1" when the regex is applied it remove it to every occurence of that prefix. |
I can confirm an issue with callback not firing because of By removing |
It's entirely unexpected. The auth challenge header format is standardised - see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate. In general it's of the form FWIW this implementation can be changed to not even use regex - it's not needed. I'll send a PR for that. Can you try to log the value of the headers? |
Figured out the possible issue but will need you to share the values of the WWW-Authenticate headers that you see. One thing which can happen is that the IdP supports multiple auth mechanisms and hence repsonds with multiple challenges - either within same We need to change the parsing logic for www-authenticate header. This proposed fix is incorrect either way. It'll end up something complicated looking like https://github.com/Azure/azure-sdk-for-python/blob/b09862b49daa95ba8b1c7360ca1d95ef9fd55011/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/http_challenge.py#L16 because sadly I can't find any good libraries for handling www-authenticate headers. |
Our Idp is ForgeRock
Seems you're right about the multiple auth-mechanisms, but this works fine with Trino JDBC (used in DBeaver) 🤷♂️ |
This days I'm out but next week I will share an example of the problem I'm refering to. |
Yes, the JDBC driver uses an HTTP library (OkHttp) which is able to return all list of challenges. Python requests collapses multi-valued HTTP headers into a single header with all values comma-separated. That's why changing the Thanks for confirming the issue. That itself makes it much easier to test the fixes. |
Fixed by #467 |
Remove the Bearer from x_redirect_server, with the count remove only the first coincidence and it make fails the redirect auth url callback.
Description
Non-technical explanation
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(X ) Release notes are required, with the following suggested text: