Repository navigation
Mongo without authentication #18323
Unanswered
ggirard07 (ggirard07)
asked this question in
Q&A
Replies: 1 comment
|
I don't think there's a switch for this today. AddMongoDB always creates a password (generates one if you don't pass it), always sets the root user env vars, and the health check uses that connection string. The resource can build a credential-less connection string internally but AddMongoDB never lets the password be null. So stripping the env vars gets you an unauthenticated mongod, but the health check still tries to log in. I'd just use a plain container for this: var mongo = builder.AddContainer("mongo", "mongo", "8.0")
.WithEndpoint(targetPort: 27017, name: "tcp", scheme: "tcp");
var mongoUrl = ReferenceExpression.Create(
$"mongodb://{mongo.GetEndpoint("tcp").Property(EndpointProperty.HostAndPort)}");
builder.AddContainer("thirdparty", "vendor/image")
.WithEnvironment("MONGO_URL", mongoUrl)
.WaitFor(mongo);Add your own no-auth IHealthCheck if you need readiness. A WithoutAuthentication() style option would be a reasonable feature request. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Default app host integration for MongoDB in Aspire requires authentication, either through explicit user/password or default admin + implicit password.
But for our use case, MongoDB is just a dependency of another third party dependency we have to run but do not own the code. This service does not support authenticated connection to MongoDB (as the default MongoDB image config from docker hub).
We can override the default configuration for MongoDB and MongoExpress through environment variables, but the respective health-checks still use the authentication and report false-positive failure in that case.
Is there a proper way to disable authentication from Aspire host integration I missed?
I understand this is probably not the advised setup, but here we are tied to third party decisions, each justifiable on their own...
All reactions