Problem/Motivation
When using the Okta integration, a user can log in. However, when logging out and openid_connect request is sent to the okta server (https://[name-withheld].oktapreview.com/oauth2/v1/logout), the following error is received:
{"errorCode":"invalid_client","errorSummary":"A client_id must be provided in the request.","errorLink":"invalid_client","errorId":"oaeBLWNYnuyT3eqdyOZde8TwA","errorCauses":[]}
Steps to reproduce
1. Install openid_connect
2. Go to /admin/config/services/openid-connect/add/okta and enter valid credentials for an Okta account app.
3. Add an openid_connect login button to the block layout.
4. Log in to the site (/user/login) using the login button (success).
5. Log out (/user/logout), and the above error is outputted from Okta.
Proposed resolution
Make sure the client_id is being sent in the logout request to Okta.
I marked this as critical, because successful logout functionality is absolutely essential. Without it, the Okta integration is incomplete.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | openid_connect-3216938-7-logout-redirect-url-domain-name-15.patch | 951 bytes | slasher13 |
| #10 | openid_connect-end_session_redirect-3215229-9.patch | 6.31 KB | daniel kulbe |
Comments
Comment #2
jcnventuraWorking on this
Comment #4
jcnventuraComment #5
daniel kulbeI still have an issue with those changes:
LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Routing\TrustedRedirectResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php)
because of the TrustedRedirectResponse for the end_session redirect. This does not happen, when the response is a simple RedirectResponse!
Comment #6
daniel kulbeComment #7
daniel kulbeThere is also an issue in line 311, without passing "TRUE", you can not call for getGeneratedUrl(), it is not necessary anyway.
May be there should be simply a simple target url redefinition instead of creating an entirely new redirect.
Comment #8
daniel kulbeStill worked on this for a while now. I could only solve the early rendering issue by executing 'user_logout()' in its own render context.
Comment #9
daniel kulbeCould not be applied to latest master, here an updated version.
Comment #10
daniel kulbeComment #11
jcnventuraA lot of the code being changed in #10 should not. If the user does not set a logout URL they should not be redirected to Drupal's frontpage. Does that leave them in the login/logout page for the IDP? Yeah. But that's what is expected when not setting the path. If the site builder wants to redirect to the frontpage, then they should configure that field as
<front>.Also, why are you setting all URLs to absolute? That I know of, only the post_logout_redirect_uri needs to be set to absolute. And a caching dependency on the logout URL and the entity? Why are these required?
I think the #10 patch would probably be a lot easier to understand if those changes were reverted.
Seems to me the only changes are:
and
Other than all the renderer dependency injection and the executeInRenderContext() which seems to be a way to mask the problem.
A problem I've not been able to reproduce, BTW.
Comment #12
slasher13see https://www.drupal.org/project/openid_connect/issues/3216938#comment-141...
Comment #13
daniel kulbeRegarding the front page redirect fallback, in case of Gluu Server I am using, see issue #3214681, the user ends up on an empty page after logout. The user is stuck there. When I leave the field empty I would have expected to end up on the default Drupal logout redirect page, as any other user, which is the front page.
The caching dependency on the entity is required because the generated redirect depends on the configuration of the provider. The caching dependency on the logout URL I added for the same reason. When I leave the configuration option empty I would use the default Drupal logout redirect page, which is not part of the entity settings.
In case of the provider does not support the end_session URL, you should not return a TrustedRedirectResponse, as the URL is always an internal URL. A reassignment of the target URL is enough.
I could not pin down the problem to a source either, only can tell it happens.
Comment #14
cmcnamee commentedI was unable to apply either of the patches #10 and #12. Composer didn't give a reason why, even in verbose mode. Is anyone else having that problem?
Are we supposed to use both patches #10 & #12 together? Or, pick one? I also tried manually using (copy/paste) the change in patch #12 alone, but that didn't work for me.
Also, I tried installing 2.x-dev and get:
Error: Call to a member function getPlugin() on null in Drupal\openid_connect\Controller\OpenIDConnectRedirectController->redirectLogout() (line 300 of /code/web/modules/contrib/openid_connect/src/Controller/OpenIDConnectRedirectController.php)
Not sure if that's related to this issue, but, it is redirectLogout() that's affected.
Comment #15
cmcnamee commentedI've tried both patches #10 and #12 separately, tried 2.x-dev, and also reverted back to 2.0.0-alpha6. All of these give the error:
Error: Call to a member function getPlugin() on null in Drupal\openid_connect\Controller\OpenIDConnectRedirectController->redirectLogout() (line 300 of /code/web/modules/contrib/openid_connect/src/Controller/OpenIDConnectRedirectController.php)
Comment #16
cmcnamee commentedMy comments on #14 and #15, I'm pretty sure are a separate issue. The error comes after a notice of undefined index on a client that I had previously deleted. I opened a new issue for that here: https://www.drupal.org/project/openid_connect/issues/3218775
Comment #18
jcnventuraAs the changes in #10 seem to be a lot of lines to hide the real problem, and the fact that #12 seems to fix the problem to some people and it is a lot simpler, I'm going to commit that one in hopes that the problem (that I never experienced) gets fixed.
Comment #20
jcnventuraComment #21
cmcnamee commentedI'm just confirming that after #16 was fixed in a different issue (it was blocking this issue), now #12 works great for me.