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

Not authorized to execute collMod during schema creation #2402

Closed
nikophil opened this issue Dec 29, 2021 · 4 comments
Closed

Not authorized to execute collMod during schema creation #2402

nikophil opened this issue Dec 29, 2021 · 4 comments

Comments

@nikophil
Copy link

Hello,

BC Break Report

Q A
BC Break yes
Version 2.3.0

Summary

Since we've upgraded to doctrine/mongo-odm 2.3.0 the authSource will always be admin even if another one is provided in the dsn with the authSource param. This leads to "authentication failed" errors.

How to reproduce

try to connect to a database which authentication database has another name than admin

thanks for your work 👍

@malarzm
Copy link
Member

malarzm commented Dec 29, 2021

@nikophil are you sure this is because of ODM and not some other library/driver update? Asking because authSource is not used anywhere in the ODM: https://github.com/doctrine/mongodb-odm/search?q=authSource

@nikophil
Copy link
Author

Hi @malarzm
I'm a sure: I looked for the culprit by dichotomy and found doctrine/mongo-odm:2.3.0:

$ composer info doctrine/mongodb-odm
# results in 2.2.3

$ bin/console doctrine:mongodb:schema:update 
Updated indexes for all classes

$ composer u doctrine/mongodb-odm:2.3.0 
Loading composer repositories with package information
Updating dependencies                                 
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading doctrine/mongodb-odm (2.2.3 => 2.3.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Downloading doctrine/mongodb-odm (2.3.0)
  - Upgrading doctrine/mongodb-odm (2.2.3 => 2.3.0): Extracting archive
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class

Executing script cache:clear [OK]

$ bin/console doctrine:mongodb:schema:update 
Updated indexes for all classes
not authorized on db to execute command { collMod: "some-collection", validator: [], validationAction: "error", validationLevel: "strict", $db: "db", lsid: { id: UUID("xxxxxxxxxxx") }, $clusterTime: { clusterTime: Timestamp(1640850344, 139), signature: { hash: BinData(0, xxxxxxxx), keyId: xxxxxxxx } } }

maybe, I'm mistaking and the root cause is not authSource parameter, but the error only occurs on a database with authentication database has a name different than admin.

BTW here some extra info:
php: 8.0.12
mongo-ext: 1.10.0
mongodb/mongodb: 1.9.0
symfony/* : 5.4.*
doctrine/mongodb-odm-bundle: 4.3.1

@malarzm
Copy link
Member

malarzm commented Dec 30, 2021

not authorized on db to execute command { collMod: "some-collection", validator: [], validationAction: "error", validationLevel: "strict", $db: "db", lsid: { id: UUID("xxxxxxxxxxx") }, $clusterTime: { clusterTime: Timestamp(1640850344, 139), signature: { hash: BinData(0, xxxxxxxx), keyId: xxxxxxxx } } }

This query comes from new feature in ODM 2.3 (#2238). Most probably the user you're authenticating with is not authorized to run collMod commands

@nikophil
Copy link
Author

thanks for this, I'll ask for a change of the authorization o my user, I'll let you know.

sorry for the misunderstanding about authsource

@malarzm malarzm changed the title Since 2.3.0 "authSource" si always "admin" not authorized to execute collMod during schema creation Dec 30, 2021
@malarzm malarzm changed the title not authorized to execute collMod during schema creation Not authorized to execute collMod during schema creation Dec 30, 2021
@malarzm malarzm closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants