meln5674 / grafana-mongodb-community-plugin

Open Source Grafana Plugin for querying MongoDB
GNU Affero General Public License v3.0
130 stars 17 forks source link

Connection error : Authentication Fail #25

Open woudanator opened 10 months ago

woudanator commented 10 months ago

Good day

Ran into a bit of an issue while trying to connect to my db. using the plugin, I am running in Grafana docker image.

URI STRING: mongodb://mwaccess:username:password@192.168.55.129:27017/sodapop-db/?authSource=sodapop-db

While trying to connect u get the below error

Ping failed: connection() error occurred during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.

Database is accessible from the docker container as I was able to connect using the mongo shell, I am sure this is a me error, but assistance would be greatly appreciated.

please let me know if you require more information

meln5674 commented 10 months ago

Your URI shouldn't contain the username and password, as this insecure, anyone who logs into your grafana instance can steal those credentials. You should instead use the username and password fields, which will obscure them and only provide them to the plugin and not the UI. I'm not certain if the plugin works with credentials directly in the connection string, but its not supported even if it does.

If it still doesn't work with the credentials provided correctly, you'll need to check the mongodb logs for the actual error.

woudanator commented 10 months ago

Thanks

I am aware was just trying it as it gave me the same error when I tried it with the username and password field.

It seems it uses the admin database for auth regardless of the Auth Source being set in the Uri string. I suspect this is hard coded maybe.

Easy to fix my end so ill fix and see if adding a user with the right permissions to the admin database fixes my problem. thanks for the assistance much appreciated.

meln5674 commented 10 months ago

I think I've found the problem. For whatever reason, setting the username/password in the mongo go driver unsets the auth source that's parsed from the URI. I'll try to find a way around this and get a release out later this week.

woudanator commented 10 months ago

ahh makes sense thanks for now i just created another super user witch ill use until the new fix is released.

meln5674 commented 10 months ago

v0.2.0+rc4 is now available, which should resolve this issue.

zekena2 commented 7 months ago

Doesn't seem to fix the problem I still get the same error.