Mongodb Force read-only via connection string
Asked Answered
H

1

7

Is there a way to force the connection to mongodb to be read-only via connection string? I don't want to have to create a read-only user in every environment to run some tests that I want to make sure don't change the database

Hereabouts answered 23/4, 2021 at 16:30 Comment(1)
No, privileges are manged by user, not by connection string. However, typically the connection string also contains the user name, so what is your problem? Creating a user is a single command - and dropping the user after your test is no problem either.Beem
P
3

No, because connection string is interpreted by the client. Access control is enforced by the server.

Peignoir answered 23/4, 2021 at 16:45 Comment(3)
I feel like this begs the question, why can't the client ask the server to ignore writes, but since it's the reality here you goHereabouts
The client can not send the writes in the first place. Why would someone send writes AND ask to ignore them.Peignoir
The someone that authors the connection string and the someone that uses the client are often different peopleHereabouts

© 2022 - 2024 — McMap. All rights reserved.