Closed (fixed)
Project:
OpenID Connect / OAuth client
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2018 at 08:40 UTC
Updated:
2 May 2018 at 10:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jibranHere is the patch.
Comment #3
jibranThis one is better. I'm opinion replacing the account in
openid_connect_connect_current_useris fine but doing so inopenid_connect_complete_authorizationdoesn't make sense.Comment #4
mario steinitzIt makes perfectly sense for certain use cases (e.g. denying access based on claims). But you are right, the signature of that hook is false. As
$accountcan be an instance of\Drupal\user\UserInterfaceorFALSE.So the better (and less invasive) approach to your issue without breaking functionality for other plugins would be removing the
UserInterfacetype hint from the$accountparameter and checking for FALSE/instance of UserInterface within your hook implementation.Comment #5
sun+1, but that is also an API change (if removing a type-hint from a hook signature can be counted as API change).
Comment #6
jibranLet's say I have a case where I want to assign a role to the new user who has just been connected. Right now with #3 I can do this.
There is no way to do that with #5.
Comment #7
mario steinitz@jibran: That is true. But the purpose of this existing hook is not manipulating the user properties. It rather is intended for checking authorization constraints or letting other modules identify and provide an account for authorization.
As it is very likely that another module is using this hook already for the above mentioned purpose, we shouldn't move it to another position, but fix the issue with the type hint only, as it was done in #5.
Then we can suggest another hook for adding user properties just before authorization/when mapping claims to user properties, which btw. is inspired by a use-case similar to yours. We wanted to add/change user roles according to attributes provided by the IdP.
Comment #8
mario steinitzComment #10
mario steinitzI committed the hook signature change as of patch in #5.
@jibran: Please try using the newly introduced hook_openid_connect_userinfo_save() for your customizations and let me know, whether you need any further assistance.
Comment #11
jibranUnfortunately, you can't save role using
hook_openid_connect_userinfo_save()becuaseopenid_connect_save_userinfo()doesn't handle that case. I created #2962023: Allow adding roles in \Drupal\openid_connect\OpenIDConnect::createUser using userinfo instead.