Skip to content
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

Update user groups at login with auth clients #5817

Open
azmeuk opened this issue Jul 28, 2022 · 2 comments
Open

Update user groups at login with auth clients #5817

azmeuk opened this issue Jul 28, 2022 · 2 comments

Comments

@azmeuk
Copy link

azmeuk commented Jul 28, 2022

My userbase is stored in an OpenID Connect server, and I would like to sync the groups defined in the OIDC server with Humhub. I looked at the code to tackle this ticket on yii2-authclient, and I noticed that AuthClientHelpers::updateUser would be a good place to update a user groups after login.

Would you be OK for a patch that would edit the updateUser method, so it would read a groups user attribute, create groups if not existing, and assign the user to those groups?

@luke-
Copy link
Contributor

luke- commented Jul 29, 2022

Sounds good to me. But I am not sure if we should extend AuthClientHelpers::updateUser with this or create a new OpenId class with image sync support.

As an example, LDAP Image Sync (Professional Edition) uses a different attribute name (jpegPhoto) and no URL but a Base64 encoded value.

Here a short overview how the LDAP AuthClient extends updateUser:

class LdapAuth extends BaseLdapAuth
{
    /**
     * @inheritdoc
     */
    public function init()
    {
        $this->on(self::EVENT_UPDATE_USER, [$this, 'onUpdateUser']);
        $this->on(self::EVENT_CREATE_USER, [$this, 'onUpdateUser']);

        // ...        

        parent::init();
    }

       /**
     * Ensure group and space mapping
     *
     * @param \yii\web\UserEvent $event
     */
    public function onUpdateUser($event)
    {
        /** @var User $user */
        $user = $event->identity;

        $attributes = $this->getUserAttributes();
   
        // Handle Profile Images and Group/Space Mappings 
 
    }

}

What do you think?

@azmeuk
Copy link
Author

azmeuk commented Jul 29, 2022

What do you think?

It sounds OK. I will try to submit patches in the coming weeks someday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants