Closed (duplicate)
Project:
OpenID Connect / OAuth client
Version:
2.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 Mar 2018 at 13:57 UTC
Updated:
9 Mar 2021 at 15:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jefuri commentedComment #3
jefuri commentedComment #4
jefuri commentedComment #5
jefuri commentedComment #6
sunThanks for the patch! Looks very clean and also applies cleanly to latest HEAD (confirmed locally).
I'm fairly sure I will also need this for my use-case very soon.
Comment #7
mario steinitzThe idea of letting other modules/the client plugin change the destination after authorization indeed is a useful suggestion. I also can imagine a lot of use cases for third-party implementations where this would be an improvement.
Yet the above approach 'captures' the userinfo alter hook. This IMHO is not the way to go. The userinfo alter hook has as clear purpose, which is changing the userinfo, not the destination after authorization.
I could imagine several other solutions:
(1) Add a login destination setting to the login block, that will be passed to the login form and as optional parameter to
OpenIDConnectSession::saveDestination(). This of course, would allow defining a target destination for the login block only.(2) Add an optional login destination setting to the OpenID Connect module, that - if set - will be used after a successful authorization.
(3) Provide a dedicated hook to alter the destination to redirect to after authorization. This hook could receive additional information as which plugin was used, whether the authorization was successful, whether an administrator has to unblock a newly created account first, and so on. It could be triggered in
OpenIDConnect::completeAuthorize(), which btw. already receives a reference to the$destination, but isn't using it.Comment #8
jefuri commentedI agree, maybe we should look into https://www.drupal.org/project/openid_connect/issues/3022086. There we could hook into the destination process and implement een alter there.
Comment #9
ccjjmartin commentedI am going to close this one. While digging into this problem I found that the authorize method didn't have the right page context (i.e. the proper destination parameter had already been stripped out). The openid_connect_save_destination() function was what I was looking for and so I recommend we continue further work in this issue: https://www.drupal.org/project/openid_connect/issues/3022086#comment-134...
If a hook to alter the destination is still desired then we should add it on that issue, but my two cents is that the new patch that I added will take whatever the destination parameter is and redirect the user to that. So anything that runs before openid_connect_save_destination() will be able to alter the destination and a hook specifically for this probably isn't necessary.
Comment #10
nileshlohar commentedRe-opening this issue.
For the use-case where we need to modify destination parameter during the login process based on the user claims or any user data and not when the login is triggered.
I dont think https://www.drupal.org/project/openid_connect/issues/3022086 In going in that direction to facilitate this use-case. (feel free to correct me here.)
Attaching a patch which supports overwriting destination parameter by setting $_SESSION['openid_connect_destination'] in either hook_openid_connect_userinfo_save() or hook_openid_connect_post_authorize() or any other hook.
Comment #11
jcnventuraNeeds a re-roll for version 2.x of the module, as 1.x is no longer getting new features.
Comment #12
jcnventuraComment #13
jcnventuraJust looked at the code in #10. It will never happen this way. Something like this is so custom that it should be implemented in custom code. I'm willing to accept the need for a pre/post-authorize hook to be able to do some action, but not this code.
In any case, that's another issue.
Setting back previous status from #9