[Bug]: First SSO login of a new user fails in Group::addUser

Aberta
#67,014 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
38/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
php

Direção de pesquisa

Start with markOrRun() in the files_sharing SharesUpdatedListener (around SharesUpdatedListener.php:154), which the trace shows being reached from Group::addUser() (Group.php:165) during a SocialLogin ProviderService::login call. Reproduce with a new user in a group that has group shares, and check that the share update throws NotFoundException on the first login. Done means the first login succeeds, the failure is logged, the user is marked for refresh, and the remaining UserAddedEvent listeners still run. Confirm the chosen approach with maintainers before coding, because the issue offers two alternatives.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

0. Needs triage 35-feedback bug
⚠️ This issue respects the following points: ⚠️
  • This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
  • This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
  • I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
  • I agree to follow Nextcloud's Code of Conduct.
  • I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description

When a user is created just-in-time on their first SSO login and is added to a group that has group shares, the login request fails with an exception thrown inside OC\Group\Group::addUser().

The membership row is already written at that point, but the remaining UserAddedEvent listeners never run. One of them is Talk's GroupMembershipListener, which adds the user to every conversation that has the group as attendee. On the second login the user is already in the group, addUser() returns early and no event is dispatched anymore. The user stays a group member but never receives anything that is derived from the event.

SharesUpdatedListener::markOrRun() runs the share update immediately as long as less than files_sharing/update_cutoff_time (default 3.0 s) has passed in the request. It only catches UserNotFoundException. For a brand-new user the home folder does not exist yet, so mounting the group shares throws OCP\Files\NotFoundException, which propagates through Group::addUser() to the controller.

Trace of the first login (trimmed):

OCP\Files\NotFoundException: /<uid>/files
  OCA\Talk\Recording\Listener->getRecordingUploadOwner          (BeforeNodeCreatedEvent)
  OC\Files\View->mkdir
  OCA\Deck\Sharing\Listener->overwriteMountPoint                (VerifyMountPointEvent)
  OCA\Files_Sharing\ShareTargetValidator->verifyMountPoint
  OCA\Files_Sharing\ShareRecipientUpdater->updateForUser
  OCA\Files_Sharing\Listener\SharesUpdatedListener->markOrRun   (SharesUpdatedListener.php:154)
  OCA\Files_Sharing\Listener\SharesUpdatedListener->updateOrMarkUser   (UserAddedEvent)
  OC\Group\Group->addUser                                       (Group.php:165)
  OCA\SocialLogin\Service\ProviderService->login                (ProviderService.php:545)

Other first logins hit a variant of the same failure, Node for share not found, fileid: <id>, via UserAddedToGroupListener::handleAutoAccept -> Manager::acceptShare -> DefaultShareProvider::createUserSpecificGroupShare -> Share::getNode().

Groups without group shares are not affected, because there is nothing to mount and nothing throws.

Steps to reproduce
  1. Set up sociallogin (third-party app) with an OIDC provider and a groups claim. The IdP returns a group that (a) has at least one group share and (b) is a group attendee of at least one Talk conversation. The group already exists.
  2. Log in as a user that does not exist in Nextcloud yet.
  3. The login ends with an error and nextcloud.log contains the trace above.
  4. Log in again; it succeeds.
  5. Open the Talk conversation of the group: the user is not an attendee, and no user_added system message exists.
Expected behavior

A failing share-mount update must not abort Group::addUser() or stop the other listeners of the same event. markOrRun() should catch the failure, log it and fall back to markUserForRefresh(). Alternatively the update could be deferred (mark only) while the user's home folder is not set up.

Nextcloud Server version

35

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.5

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "htaccess.RewriteBase": "/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "/var/www/html/apps",
                "url": "/apps",
                "writable": false
            },
            {
                "path": "/var/www/html/custom_apps",
                "url": "/custom_apps",
                "writable": true
            }
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "filelocking.enabled": true,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.example.org",
            "mail.example.org",
            "nextcloud-web"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "35.0.3.2",
        "overwriteprotocol": "https",
        "overwrite.cli.url": "https://cloud.example.org",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "activity_expire_days": 60,
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "tls",
        "mail_sendmailmode": "smtp",
        "mail_smtpauth": 1,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVEVALUE***","mail_smtpport": "587",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtpdebug": true,
        "maintenance": false,
        "loglevel": "1",
        "has_rebuilt_cache": true,
        "share_folder": "/Geteilte Dateien",
        "theme": "",
        "skeletondirectory": "",
        "default_phone_region": "DE",
        "maintenance_window_start": 1,
        "social_login_auto_redirect": true,
        "enable_lazy_objects": false,
        "session_lifetime": 1296000,
        "token_auth_token_retention": 15552000
    }
}
List of activated Apps
Enabled:
 - activity: 8.0.0
 - admin_audit: 2.0.0
 - app_api: 35.0.0
 - appointments: 2.8.8
 - appstore: 2.0.0
 - bruteforcesettings: 8.0.0
 - calendar: 6.6.5
 - camerarawpreviews: 1.3.0
 - circles: 35.0.0
 - cloud_federation_api: 2.0.0
 - contacts: 8.10.0
 - contactsinteraction: 2.0.0
 - dashboard: 8.0.0
 - dav: 2.0.1
 - deck: 1.19.2
 - drawio: 4.3.11
 - eurooffice: 11.0.6
 - event_update_notification: 2.10.0
 - external: 10.0.0
 - federatedfilesharing: 2.0.0
 - federation: 2.0.0
 - files: 3.0.0
 - files_downloadlimit: 5.3.0
 - files_fulltextsearch: 35.0.1
 - files_lock: 35.0.1
 - files_pdfviewer: 8.0.0
 - files_reminders: 2.0.0
 - files_sharing: 2.0.1
 - files_trashbin: 2.0.0
 - files_versions: 2.0.0
 - forms: 5.4.2
 - group_default_quota: 0.1.16
 - groupfolders: 23.0.1
 - guests: 4.10.1
 - impersonate: 6.0.0
 - libresign: 15.0.12
 - logreader: 8.0.0
 - lookup_server_connector: 2.0.0
 - nextcloud_announcements: 7.0.0
 - notifications: 8.0.1
 - notify_push: 1.4.2
 - oauth2: 2.0.0
 - office: 1.1.0
 - password_policy: 7.0.0
 - passwords: 2026.11.20
 - polls: 9.3.0
 - privacy: 7.0.0
 - profile: 2.0.0
 - provisioning_api: 2.0.0
 - quota_warning: 1.25.0
 - recommendations: 8.0.0
 - related_resources: 6.0.0
 - serverinfo: 7.0.0
 - settings: 2.0.0
 - sharebymail: 2.0.0
 - sharing: 1.0.5
 - sociallogin: 6.6.3
 - spreed: 25.0.8
 - systemtags: 2.0.0
 - text: 9.0.2
 - theming: 3.0.0
 - twofactor_backupcodes: 2.0.0
 - twofactor_totp: 17.1.0
 - unroundedcorners: 1.1.6
 - updatenotification: 2.0.0
 - user_status: 2.0.0
 - viewer: 8.0.0
 - webhook_listeners: 2.0.0
 - workflowengine: 3.0.0
 - worktime: 0.26.0
Disabled:
 - apporder: 0.15.0 (installed 0.15.0)
 - comments: 2.0.0 (installed 1.19.0) 
 - encryption: 3.0.1
 - files_external: 2.0.0
 - files_markdown: 2.4.1 (installed 2.4.1)
 - files_rightclick: 0.15.1 (installed 1.6.0)
 - files_trackdownloads: 1.11.0 (installed 1.11.0)
 - firstrunwizard: 8.0.0 (installed 2.18.0)
 - formvox: 1.5.0 (installed 1.5.0)
 - onlyoffice: 10.2.1 (installed 10.2.1)
 - photos: 8.0.0 (installed 1.3.0)
 - ransomware_protection: 1.14.0 (installed 1.14.0)
 - sharepermissions: 1.0.1 (installed 1.0.1)
 - support: 7.0.0 (installed 1.4.0)
 - survey_client: 7.0.0 (installed 1.9.0)
 - suspicious_login: 13.0.0 (installed 4.2.1)
 - twofactor_nextcloud_notification: 9.0.0
 - user_ldap: 2.0.0
 - weather_status: 2.0.0 (installed 1.1.0)
Nextcloud Signing status
Technical information
=====================
The following list covers which files have failed the integrity check. Please read
the previous linked documentation to learn more about the errors and how to fix
them.

Results
=======
- passwords
	- INVALID_HASH
		- lib/Services/EnvironmentService.php
	- EXTRA_FILE
		- lib/Services/EnvironmentService.php.orig-20261120

Raw output
==========
Array
(
    [passwords] => Array
        (
            [INVALID_HASH] => Array
                (
                    [lib/Services/EnvironmentService.php] => Array
                        (
                            [expected] => bb31a08257767b6a91aaaf462841c31366d44419eb1ac7c274f110368b5c0d9af9d0d8ae0ade44399cb738b05f910cacee3b976e516754f0baccf0b33fec7f19
                            [current] => cd98e3c0374d0af4da536071931262fed6fb42563b5b8bfe793cc02a867b11dd4dff22d4199de92ac9e30995c951d5e3dd7b18947cdfcf113853d2405cae05b6
                        )

                )

            [EXTRA_FILE] => Array
                (
                    [lib/Services/EnvironmentService.php.orig-20261120] => Array
                        (
                            [expected] => 
                            [current] => bb31a08257767b6a91aaaf462841c31366d44419eb1ac7c274f110368b5c0d9af9d0d8ae0ade44399cb738b05f910cacee3b976e516754f0baccf0b33fec7f19
                        )

                )

        )

)

(local hotfix for a bug in the passwords app)
Nextcloud Logs

Additional info

Workaround: occ config:app:set files_sharing update_cutoff_time --value=0 --type=float. markOrRun() then only marks the user for refresh instead of running the update, so nothing throws.

Linguagem predominante
PHP
Estrelas
37.6k
Forks
5.4k
Merge médio
1d 13h
PRs com merge (30d)
623

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de nextcloud/server

Todas as issues de nextcloud/server

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.