-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Userinfo #24
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 4690358589Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
The idea of persisting the user properties in the plugin itself is great, I have used it in the past when developing "login with facebook" or "login with twitter" (in the pre-oauth-era). I would add some documentation about the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not try it, but the code seems fine.
self._userdata_by_userid[user.getId()] = UserPropertySheet( | ||
user.getId(), **userProps | ||
) | ||
if self.create_user: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With self.create_user
we create a standard Plone user like you would get when using the Users and Groups control panel, right?
I doubt that it is then still needed to set self._userdata_by_userid
.
Ah, but when create_user
is False for a while, and only later switched to True, and we do not update self._userdata_by_userid
, it may get outdated and not in sync with the standard member data.
We could remove existing data when create_user
is True.
Hard to say for sure what is best without trying it. But should be okay like it is now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file is not used.
I think that could work, yes, and make things a bit simpler. |
I tried this PR out in combination with LDAP, and there it is working fine for our use case. Let me share all my notes. On a test site (Plone Classic UI 6.0.8, Python 3.11) we have You could wonder if LDAP is even still needed in this case. But with the current oidc plugin, you only get information for users who have authenticated. For the moment, I think we want all users, so LDAP is still needed. Note: in our setup, we want to handle groups in Plone, and are not interested in what we get here from either LDAP or oidc. Some settings:
Sample oidc userinfo that we get from Keycloak:
The fullname that I get from LDAP is actually slightly different: "Maurits van Rees (ext)", for external. Initially with this setup, I got two users, one with and one without "ext" in the fullname One was from LDAP, with user id 'ma.vanrees', one from oidc, with as user id the id from the "sub" property. So I removed the user with the sub id from One problem though: whenever I login with oidc, this plugin calls So now let's check how the current PR influences the situation. Okay, switch to this branch, restart, apply the upgrade step. Now the insufficient access error is gone. Why? Because when calling setProperties PlonePAS goes through all property sheets in order, and tries to set a property. Once a property (say the fullname) is set, PlonePAS no longer tries to set it in any further property sheets. So once it reaches the LDAP property sheet, no properties are left to be set, so there is no error. So now for fun you can play with the order of the properties plugins in I was also testing the new "Mapping from userinfo to memberdata property" from this PR:
So it works. Thanks! It could use some tests, and documentation. |
@mauritsvanrees thanks!
I need to learn the new tests introduced by Erico. But I think I can make up some time this weekend. |
Management of user properties from oidc userinfo.
Widely inspired by https://github.com/collective/pas.plugins.headers/blob/master/src/pas/plugins/headers/plugins.py#L404 and https://github.com/collective/pas.plugins.authomatic/blob/main/src/pas/plugins/authomatic/useridentities.py#L30.
The idea could be to also implement
IUserEnumeration
on the implemented properties storage (https://github.com/collective/pas.plugins.oidc/blob/userinfo/src/pas/plugins/oidc/plugins.py#L157) and completely eliminate the code related to the creation of a user (https://github.com/collective/pas.plugins.oidc/blob/userinfo/src/pas/plugins/oidc/plugins.py#L193) in the source_users storage.@erral @mauritsvanrees opinions on this?