-
Notifications
You must be signed in to change notification settings - Fork 10
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
DoCertExchange function does not use certificates in request to Keycloak #1008
Comments
Can you provide more details on your Keycloak setup? What type of x509 Auth flow do you have setup for Keycloak? The standard(default) Keycloak x509 Cert Lookup Provider does not required any custom headers |
See this Unit test for an example of setting up TLS config passed into the SDK |
Not sure if they HAVE to be headers for this type of authentication, however, this is what worked for me when trying to authenticate directly with keycloak
I got this from a keycloak discussion board. With that being said though, the Cert exchange code in the SDK does nothing with the Certificates tht are passed with the sdk.WithTLSCredentials(). It does add the audience from the CertExchangeInfo struct, but it never does anything with the underlying certificates. Ive seen that unit test, and unfortuntely a lot of those functions are internal so when importing the sdk we don't have access to them. The only way to instantiate the cert exchange is through the sdk.New() passing it sdk.WithTLSCredentials()
This is the code in those functions that are used. exchangeinfo is the struct that has the TLS Config and the array of audiences... in the When running this end to end the keycloak server always responds with no x509 certificate. |
When you pass sdk.WithTLSCredentials into the sdk.New() it does go through and run the DoCertExchange internally, but we cannot just stand it up the way you do in the unit test due to Go's internal restriction on packages |
I do notice, that in the Unit Test, the TLS Config passed to the client is the one where the sampleuser certificates are being applied, this may be why there doesnt need to be any additional custom headers. With that being said, when using the sdk.New() the TLS Config that gets passed into the client that is passed into |
Just to further test, I changed this
to this:
And this caused the authentication to be successful, by adding the TLS config that is set in exchangeInfo versus the on config in the TLS Config for the sdk. |
Fixed by #1043 |
🤖 I have created a release *beep* *boop* --- ## [0.2.9](sdk/v0.2.8...sdk/v0.2.9) (2024-07-02) ### Features * **sdk:** support unsafe policy service in SDK ([#1076](#1076)) ([ca88554](ca88554)) ### Bug Fixes * **core:** Autobump sdk ([#1070](#1070)) ([4ca372c](4ca372c)) * Issue [#1008](#1008) : Use exchange info's TLS Configuration for cert based auth ([#1043](#1043)) ([93d8f70](93d8f70)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [0.2.9](sdk/v0.2.8...sdk/v0.2.9) (2024-07-02) ### Features * **sdk:** support unsafe policy service in SDK ([#1076](#1076)) ([ca88554](ca88554)) ### Bug Fixes * **core:** Autobump sdk ([#1070](#1070)) ([4ca372c](4ca372c)) * Issue [#1008](#1008) : Use exchange info's TLS Configuration for cert based auth ([#1043](#1043)) ([93d8f70](93d8f70)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
I am trying to utilize the sdk to exchange x509 certificates for AccessTokens to be used against the platform. After multiple attempts all resulting in {"error_description":"X509 client certificate is missing.","error":"invalid_request"} I decided to try and authenticate directly with keycloak first. I was successful and retrieved a jwt from keycloak.
This made me dive into the sdk code and I noticed that the DoCertExchange workflow never adds any of the headers or certificates needed to authenticate with the IDP and get the access token.
The text was updated successfully, but these errors were encountered: