I want to influence the way the redirect takes place.
This is possible when passing the $destination to the hook_openid_connect_userinfo_alter().
This hook is called in:

  • openid_connect_complete_authorization
  • openid_connect_connect_current_user
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    jefuri created an issue. See original summary.

    jefuri’s picture

    jefuri’s picture

    jefuri’s picture

    jefuri’s picture

    Status: Active » Needs review
    sun’s picture

    Thanks 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.

    mario steinitz’s picture

    Status: Needs review » Needs work

    The 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.

    jefuri’s picture

    I 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.

    ccjjmartin’s picture

    Status: Needs work » Closed (duplicate)

    I 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.

    nileshlohar’s picture

    Assigned: jefuri » Unassigned
    Status: Closed (duplicate) » Needs review
    StatusFileSize
    new2.72 KB

    Re-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.

    jcnventura’s picture

    Version: 8.x-1.x-dev » 2.x-dev

    Needs a re-roll for version 2.x of the module, as 1.x is no longer getting new features.

    jcnventura’s picture

    Status: Needs review » Needs work
    jcnventura’s picture

    Just 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