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

[ bug ]V1.8.2 使用root权限账号,mongo无法查询。 #1291

Closed
gaoqiang-0327 opened this issue Dec 21, 2021 · 8 comments
Closed

[ bug ]V1.8.2 使用root权限账号,mongo无法查询。 #1291

gaoqiang-0327 opened this issue Dec 21, 2021 · 8 comments

Comments

@gaoqiang-0327
Copy link

部署方式:手工部署
版本:1.8.2
问题:配置好root权限的账号密码后,数据库设置为admin。只能查询admin库下的表。其他库查询均报错。
报错:
[2021-12-21 14:06:46,655][MainThread:139741727864640][task_id:default][query.py:169][ERROR]- 查询异常报错,查询语句:db.store.find()
,错误信息:Traceback (most recent call last):
File "/opt/app/archery/Archery/sql/query.py", line 87, in query
query_engine.get_connection(db_name=db_name)
File "/opt/app/archery/Archery/sql/engines/mongo.py", line 510, in get_connection
self.conn[self.db_name].authenticate(self.user, self.password, self.db_name)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/database.py", line 1495, in authenticate
connect=True)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/mongo_client.py", line 781, in _cache_credentials
sock_info.authenticate(credentials)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/pool.py", line 810, in authenticate
auth.authenticate(credentials, self)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/auth.py", line 673, in authenticate
auth_func(credentials, sock_info)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/auth.py", line 591, in _authenticate_default
return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-1')
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/auth.py", line 295, in _authenticate_scram
res = sock_info.command(source, cmd)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/pool.py", line 694, in command
exhaust_allowed=exhaust_allowed)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/network.py", line 162, in command
parse_write_concern_error=parse_write_concern_error)
File "/opt/app/archery/Python-3.6.5/venv4archery/lib/python3.6/site-packages/pymongo/helpers.py", line 168, in _check_command_response
max_wire_version)
pymongo.errors.OperationFailure: Authentication failed., full error: {'operationTime': Timestamp(1640066806, 6), 'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed', '$clusterTime': {'clusterTime': Timestamp(1640066806, 6), 'sig
nature': {'hash': b"\xa9\xac'FK\x89\xcc\x83\x94\x1b\xaa\xf9\xbfA\x02\n\xac%:\xec", 'keyId': 7002904756918157317}}}

@gaoqiang-0327
Copy link
Author

先把1.8.1的代码拷过来好使了

@hhyo
Copy link
Owner

hhyo commented Dec 21, 2021

#1168

@weideguo
Copy link
Collaborator

@hhyo 应该是mongo.py#L507-L510的实现有问题

    auth_db = self.instance.db_name or 'admin'
    self.conn = pymongo.MongoClient(self.host, self.port, authSource=auth_db, connect=True,
                                    connectTimeoutMS=10000)
    if self.user and self.password:
        self.conn[self.db_name].authenticate(self.user, self.password, auth_db)

建议改成这样,即明确区分认证的数据库、实际使用的数据库

@LeoQuote
Copy link
Collaborator

@hhyo 应该是mongo.py#L507-L510的实现有问题

    auth_db = self.instance.db_name or 'admin'
    self.conn = pymongo.MongoClient(self.host, self.port, authSource=auth_db, connect=True,
                                    connectTimeoutMS=10000)
    if self.user and self.password:
        self.conn[self.db_name].authenticate(self.user, self.password, auth_db)

建议改成这样,即明确区分认证的数据库、实际使用的数据库

方便的话直接提pr吧

@LeoQuote
Copy link
Collaborator

Duplicate of #1168

@LeoQuote LeoQuote marked this as a duplicate of #1168 Dec 22, 2021
@hhyo
Copy link
Owner

hhyo commented Dec 22, 2021

这个是逻辑有变动吧,以前的版本是root可以查所有的集合 @LeoQuote

weideguo added a commit to weideguo/Archery that referenced this issue Dec 22, 2021
hhyo added a commit that referenced this issue Dec 24, 2021
修复创建mongodb原生连接时的错误 (#1291)
@Myshiner
Copy link

这个现在就是查不了除admin外其他库的数据,已经是root角色了,正常查询只需要readAnyDatabase角色就可以了,这是要到1.8.3版本才能修复吗?

@Myshiner
Copy link

Reference

我已经将sql/engines/mongo.py下对应的代码改成上面的,然后重启了archery容器,依旧会报
“查询异常报错,错误信息:Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'}”
还是查不了除admin外别的库

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

5 participants