SoftInstigate / restheart

Open Source Low-code API development framework Featuring ready-to-go Security and MongoDB API
http://softinstigate.github.io/restheart/
GNU Affero General Public License v3.0
792 stars 170 forks source link

Connect to Atlas Cluster #512

Open sgkamakama opened 1 week ago

sgkamakama commented 1 week ago

I am getting connection error when using mongodb+srv://username:password@host/db.

I am wondering if Restheart support mongodb+srv

Thank you

mkjsix commented 1 week ago

There are few things I am sure of in life, one of them is that RESTHeart fully supports the mongodb+srv connection string, as most of our projects are running with MongoDB Atlas. Generally speaking, RESTHeart depends on this on the offcial MongoDB Java driver

If you can provide here your connection errors, maybe we could find the real reason.

sgkamakama commented 1 week ago

This is my script

@.***/catalyst?retryWrites=true&authenticationDatabase=admin&replicaSet=atlas-u1k7lv-shard-0&readPreference=secondary&readPreferenceTags=nodeType:ANALYTICS&srvServiceName=mongodb&readConcernLevel=local

Error

com.mongodb.MongoQueryException: Command failed with error 13 (Unauthorized): 'not authorized on catalyst to execute command { find: "_properties", readConcern: { level: "local" }, filter: { _id: "_properties" }, limit: 1, singleBatch: true, $db: "catalyst", $clusterTime: { clusterTime: Timestamp(1718703618, 1), signature: { hash: BinData(0, C5BD84F5C5AAC0E8F42A7EE50F44B48491472E47), keyId: 7365678082948071430 } }, lsid: { id: UUID("3d6d7b9c-68b9-456c-bac0-098865eadd92") }, $readPreference: { mode: "secondary", tags: [ { nodeType: "ANALYTICS" } ] } }' on server pl-0-eu-central-1.bozk8.mongodb.net:1027. The full response is {"ok": 0.0, "errmsg": "not authorized on catalyst to execute command { find: \"_properties\", readConcern: { level: \"local\" }, filter: { _id: \"_properties\" },

From: Maurizio Turatti @.> Sent: Tuesday, 18 June 2024 09:46 To: SoftInstigate/restheart @.> Cc: Greene S. Kamakama @.>; Author @.> Subject: Re: [SoftInstigate/restheart] Connect to Atlas Cluster (Issue #512)

There are few things I am sure of in life, one of them is that RESTHeart fully supports the mongodb+srv connection string, as most of our projects are running with MongoDB Atlas. Generally speaking, RESTHeart depends on this on the offcial MongoDB Java driver

If you can provide here your connection errors, maybe we could find the real reason.

— Reply to this email directly, view it on GitHubhttps://github.com/SoftInstigate/restheart/issues/512#issuecomment-2175423497, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BB7ZII5IRJ6RAYLG2SFHL3LZH7QS5AVCNFSM6AAAAABJOTZ2XOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZVGQZDGNBZG4. You are receiving this because you authored the thread.Message ID: @.**@.>>

The information contained in this transmission is confidential. It is intended solely for the use of the individual(s) or Companies and Intellectual Property Authority to which it is addressed. Any disclosure, copying or further distribution is not permitted unless such privilege is explicitly granted in writing by Companies and Intellectual Property Authority. Furthermore, Companies and Intellectual Property Authority is not responsible for the proper and complete transmission of the substance of this communication, nor for any delay in its receipt. If you have received this email content by mistake, please notify the sender immediately by returning the email and delete the email. Please note that the recipient must scan this email and any attached files for viruses and the likes.

sgkamakama commented 1 week ago

This is my script it give

@.***/catalyst?retryWrites=true&authenticationDatabase=admin&replicaSet=atlas-u1k7lv-shard-0&readPreference=secondary&readPreferenceTags=nodeType:ANALYTICS&srvServiceName=mongodb&readConcernLevel=local

Error

com.mongodb.MongoQueryException: Command failed with error 13 (Unauthorized): 'not authorized on catalyst to execute command { find: "_properties", readConcern: { level: "local" }, filter: { _id: "_properties" }, limit: 1, singleBatch: true, $db: "catalyst", $clusterTime: { clusterTime: Timestamp(1718703618, 1), signature: { hash: BinData(0, C5BD84F5C5AAC0E8F42A7EE50F44B48491472E47), keyId: 7365678082948071430 } }, lsid: { id: UUID("3d6d7b9c-68b9-456c-bac0-098865eadd92") }, $readPreference: { mode: "secondary", tags: [ { nodeType: "ANALYTICS" } ] } }' on server pl-0-eu-central-1.bozk8.mongodb.net:1027. The full response is {"ok": 0.0, "errmsg": "not authorized on catalyst to execute command { find: \"_properties\", readConcern: { level: \"local\" }, filter: { _id: \"_properties\" },

From: Maurizio Turatti @.> Sent: Tuesday, 18 June 2024 09:46 To: SoftInstigate/restheart @.> Cc: Greene S. Kamakama @.>; Author @.> Subject: Re: [SoftInstigate/restheart] Connect to Atlas Cluster (Issue #512)

There are few things I am sure of in life, one of them is that RESTHeart fully supports the mongodb+srv connection string, as most of our projects are running with MongoDB Atlas. Generally speaking, RESTHeart depends on this on the offcial MongoDB Java driver

If you can provide here your connection errors, maybe we could find the real reason.

— Reply to this email directly, view it on GitHubhttps://github.com/SoftInstigate/restheart/issues/512#issuecomment-2175423497, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BB7ZII5IRJ6RAYLG2SFHL3LZH7QS5AVCNFSM6AAAAABJOTZ2XOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZVGQZDGNBZG4. You are receiving this because you authored the thread.Message ID: @.**@.>>

The information contained in this transmission is confidential. It is intended solely for the use of the individual(s) or Companies and Intellectual Property Authority to which it is addressed. Any disclosure, copying or further distribution is not permitted unless such privilege is explicitly granted in writing by Companies and Intellectual Property Authority. Furthermore, Companies and Intellectual Property Authority is not responsible for the proper and complete transmission of the substance of this communication, nor for any delay in its receipt. If you have received this email content by mistake, please notify the sender immediately by returning the email and delete the email. Please note that the recipient must scan this email and any attached files for viruses and the likes.

mkjsix commented 1 week ago

The error message you're encountering, not authorized on catalyst to execute command, indicates that the user you are using to connect to the MongoDB Atlas cluster does not have the required permissions to execute the query on the catalyst database. Check user permissions and if the user does not have the necessary permissions, you can update the user's roles to include read access to the catalyst database. Add a role such as read or readAnyDatabase to the user.

sgkamakama commented 1 week ago

Sorry for sending another email.

When connecting with the same URL using mongosh shell (shown below), Studio T3 and MongoDB Compas I am able to connect. I have also attached my custom yml. Your assistance will be much appreciated

Thank you

@.***

From: Maurizio Turatti @.> Sent: Tuesday, 18 June 2024 09:46 To: SoftInstigate/restheart @.> Cc: Greene S. Kamakama @.>; Author @.> Subject: Re: [SoftInstigate/restheart] Connect to Atlas Cluster (Issue #512)

There are few things I am sure of in life, one of them is that RESTHeart fully supports the mongodb+srv connection string, as most of our projects are running with MongoDB Atlas. Generally speaking, RESTHeart depends on this on the offcial MongoDB Java driver

If you can provide here your connection errors, maybe we could find the real reason.

— Reply to this email directly, view it on GitHubhttps://github.com/SoftInstigate/restheart/issues/512#issuecomment-2175423497, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BB7ZII5IRJ6RAYLG2SFHL3LZH7QS5AVCNFSM6AAAAABJOTZ2XOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZVGQZDGNBZG4. You are receiving this because you authored the thread.Message ID: @.**@.>>

The information contained in this transmission is confidential. It is intended solely for the use of the individual(s) or Companies and Intellectual Property Authority to which it is addressed. Any disclosure, copying or further distribution is not permitted unless such privilege is explicitly granted in writing by Companies and Intellectual Property Authority. Furthermore, Companies and Intellectual Property Authority is not responsible for the proper and complete transmission of the substance of this communication, nor for any delay in its receipt. If you have received this email content by mistake, please notify the sender immediately by returning the email and delete the email. Please note that the recipient must scan this email and any attached files for viruses and the likes.

sgkamakama commented 1 week ago

Thanks a lot, I will check and test.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Maurizio Turatti @.> Sent: Tuesday, June 18, 2024 3:46:46 pm To: SoftInstigate/restheart @.> Cc: Greene S. Kamakama @.>; Author @.> Subject: Re: [SoftInstigate/restheart] Connect to Atlas Cluster (Issue #512)

The error message you're encountering, not authorized on catalyst to execute command, indicates that the user you are using to connect to the MongoDB Atlas cluster does not have the required permissions to execute the query on the catalyst database. Check user permissions and if the user does not have the necessary permissions, you can update the user's roles to include read access to the catalyst database. Add a role such as read or readAnyDatabase to the user.

— Reply to this email directly, view it on GitHubhttps://github.com/SoftInstigate/restheart/issues/512#issuecomment-2176146985, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BB7ZIIZMTFNMZQWLXCFB3HTZIA237AVCNFSM6AAAAABJOTZ2XOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZWGE2DMOJYGU. You are receiving this because you authored the thread.Message ID: @.***>

The information contained in this transmission is confidential. It is intended solely for the use of the individual(s) or Companies and Intellectual Property Authority to which it is addressed. Any disclosure, copying or further distribution is not permitted unless such privilege is explicitly granted in writing by Companies and Intellectual Property Authority. Furthermore, Companies and Intellectual Property Authority is not responsible for the proper and complete transmission of the substance of this communication, nor for any delay in its receipt. If you have received this email content by mistake, please notify the sender immediately by returning the email and delete the email. Please note that the recipient must scan this email and any attached files for viruses and the likes.