JSONDecodeError when OIDCRedirectURI is the same as the Keystone OIDC auth endpoint
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Identity (keystone) |
Fix Released
|
Undecided
|
Jadon Naas | ||
OpenStack Keystone OIDC Integration Charm |
In Progress
|
Undecided
|
Jadon Naas | ||
puppet-keystone |
Fix Released
|
Medium
|
Takashi Kajinami |
Bug Description
This bug is about test failures for jammy-caracal, jammy-bobcat, and jammy-antelope in cherry-pick commits from this change:
https:/
That change fixed some bugs in the Keystone OpenIDC charm and added some additional configuration options to help with proxies.
The tests all fail with a JSONDecodeError during the Zaza tests for the Keystone OpenIDC charm. Here is an example of the error:
Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/home/
return complexjson.
File "/usr/lib/
return _default_
File "/usr/lib/
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/
raise JSONDecodeError
json.decoder.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/
self.
File "/home/
self.
File "/home/
self._auth_ref = self.auth.
File "/home/
auth_ref = self.get_
File "/home/
return access.
File "/home/
body = resp.json()
File "/home/
raise RequestsJSONDec
requests.
clean_up ListServer: Expecting value: line 1 column 1 (char 0)
END return value: 1
According to debug output, the failure happens during the OIDC authentication flow. Testing using the OpenStack CLI shows the failure happen right after this request:
REQ: curl -g -i --insecure -X POST https:/
Starting new HTTPS connection (1): 10.70.143.111:5000
RESP: [200] Connection: Keep-Alive Content-Length: 0 Date: Tue, 30 Jul 2024 19:28:17 GMT Keep-Alive: timeout=75, max=1000 Server: Apache/2.4.52 (Ubuntu)
RESP BODY: Omitted, Content-Type is set to None. Only text/plain, application/json responses have their bodies logged.
This request is unusual in that the request is a POST request with no request body, and the response is an empty response. The empty response causes the JSONDecodeError because the keystoneauth package expects a JSON document to return from the request for a Keystone token. The empty response causes the JSONDecodeError because an empty string is not a valid document.
This strange behavior happens due to a misconfiguration in the mod_auth_openidc Apache configuration. I looked up how Kolla-Ansible configures OpenIDC in Keystone, and I noticed that they used a different value for the OIDCRedirectURI in the mod_auth_openidc Apache configuration than the Keystone OpenIDC charm. The value of OIDCRedirectURI is supposed to be a fake URI that does not map to any real URI in the protected service. The fake URI should be protected by mod_auth_openidc in Apache's configuration. When someone accesses the path in OIDCRedirectURI mod_auth_openidc handles the request and returns an empty response.
In our configuration, the OIDCRedirectURI is the same URI as the Keystone federation protocol authentication endpoint. Keystone generates the federation protocol authentication endpoint dynamically based on the identity provider and federation protocol configured in Keystone. Here is an example of a federation protocol endpoint for a Keystone identity provider named "keycloak" using a Keystone federation protocol called "openid":
/v3/OS-
When Keystone is attempting to access the Keystone federation protocol authentication endpoint, mod_auth_openidc is intercepting the request and returning an empty response. This is blocking Keystone from properly handling the OIDC authentication flow.
If you change OIDCRedirectURI to something other than your federation protocol authentication endpoint, Keystone can complete the OIDC authentication flow successfully.
This contradicts the configuration outlined in the official Keystone federation configuration documentation at https:/
Changed in puppet-keystone: | |
assignee: | nobody → Takashi Kajinami (kajinamit) |
importance: | Undecided → Medium |
Here is a corrected Apache configuration for mod_auth_openidc that should illustrate the problem and the solution.