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

Failed to provision user #903

Open
dacrudg opened this issue Jul 25, 2024 · 4 comments
Open

Failed to provision user #903

dacrudg opened this issue Jul 25, 2024 · 4 comments
Labels
bug Something isn't working discussion priority: normal question Further information is requested

Comments

@dacrudg
Copy link

dacrudg commented Jul 25, 2024

Hi,

I have an existing Nextcloud with users already created from LDAP. I'm using Authelia for SSO, and wanting to login through Authelia and it bring up the existing users Files, Mail, etc. (Not create a new user).

I'm using the mappings-id setting for user_oidc to match the same one LDAP uses, and I also have auto_provision = false in config.php (To let LDAP take user creation). It always gives me the error below.
I've tried every setting for mappings-id as well (preferred_username, uid, mail, etc).

"Access Forbidden"
Failed to provision the user

I can't see to find any log files or where to start debugging this. I have found another user that had the same issue (#869) and set the mappings-id for users to preferred_username but that doesn't do anything for me.
If I take auto_provision = false out of Nextcloud then it will work, but it creates a totally new user in Nextcloud and doesn't use the existing user from LDAP.
It seems if auto_provision = false is set in Nextcloud then nothing will work to even login, and always gives the "Failed to provision the user" error.

I have also unchecked "Use unique user ID" box and tried with it. It has no difference. This is on user_oidc: 6.0.0 and user_oidc: 5.0.3

Any help would be much appreciated. Thank you

@dacrudg
Copy link
Author

dacrudg commented Jul 26, 2024

I modified the LoginController.php where this "Failed to provision" error occurs to dump the userId to a file username.txt, and it returns "root" in the file.
I'm not sure where it is getting "root" from as $userId

           // get user ID attribute
            $uidAttribute = $this->providerService->getSetting($providerId, ProviderService::SETTING_MAPPING_UID, 'sub');
            $userId = $idTokenPayload->{$uidAttribute} ?? null;
            $fp = fopen("username.txt",'a+');
            $fwrite = fwrite($fp, "," . $userId);
            if ($userId === null) {
                    $message = $this->l10n->t('Failed to provision the user');
                    echo $uidAttribute;
                    return $this->build403TemplateResponse($message, Http::STATUS_BAD_REQUEST, ['reason' => 'failed to provision user']);
            }

@dacrudg
Copy link
Author

dacrudg commented Jul 29, 2024

OK, now I've confirmed it is setting userId properly in LoginController.php until it gets here:
userId is correct at the beginning.

            $this->userManager->search($userId);
            $this->ldapService->syncUser($userId);
            $userFromOtherBackend = $this->userManager->get($userId);

userFromOtherBackend becomes null at the end here

@ToXinE
Copy link

ToXinE commented Aug 30, 2024

same here. I add authentik but I want nextcloud to use the users already created in authentik and not create new ones.

Edit:
I managed to solve my problem following https://docs.goauthentik.io/integrations/services/nextcloud/ and especiallly the part that add an attribute to each user you want to map in authentik :

To connect to an already existing Nextcloud user, set the "nextcloud_user_id" property in the user's attributes. This must be set for each individual user.

The value of nextcloud_user_id must match the field username of the user on the Nextcloud instance. On Nextcloud, go to Users to see the username of the user you are trying to connect to (Under user's Display name). If set to a value, for example goauthentik, it will try to connect to the goauthentik user on the Nextcloud instance. Otherwise, the user's UUID will be used.

@edward-ly edward-ly added the bug Something isn't working label Sep 17, 2024
@edward-ly edward-ly added question Further information is requested discussion labels Oct 3, 2024
@edward-ly
Copy link
Contributor

@dacrudg Did the above mapping work for you? If so, we'll consider this issue closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion priority: normal question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants