-
Notifications
You must be signed in to change notification settings - Fork 540
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
Revisit Redis password options #3838
Comments
Hey, @DamianEdwards can I take this? |
@Alirexaa to add the option to set a password via |
Per @eerhardt: we still want to look at this one, but it won't make it into 8.2 so moving to 9.0. |
Moving out of 9.0 as this requires more work than simply adding some variables to the Redis container. We still want to do this, but it won't make it by 9.0. |
Reopening as this change needed to be reverted for 9.1. See
We will need to decide how to enable password protection in Redis containers in a future release. |
After a bit of investigation, here's what I found. To set a password in the Redis container, there are 2 options (see Set password and other options via ENV variable (redis/docker-library-redis#46)):
Doing this directly isn't secure. We tried taking approach (1) in Add Password To Redis (dotnet/aspire#4642), but this fails to deploy because The same problem exists if we just purely bind mount the config file. First One option for taking the 2nd route is to write a config file into an ACA secret, and then mount that secret as a file. See https://learn.microsoft.com/en-us/azure/container-apps/manage-secrets?tabs=arm-template#secrets-volume-mounts. We could then pass that file as the conf file for the redis instance. However, this is specific for ACA and we would need to do something else at local run time. And potentially have something different for other environments. The route I think we can go down that is secure and works is to use option (1), but pass the password via an environment variable, like we do everywhere else. Then we can set the environment variable via a secret in ACA, just like everything else. To do this, we can use the solution in https://stackoverflow.com/a/72593084: var redisPassword = ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, "redis-pass");
var cache = builder.AddRedis("cache")
.WithEntrypoint("/bin/sh")
.WithArgs("-c", "redis-server --requirepass $REDIS_PASSWORD")
.WithEnvironment(context =>
{
context.EnvironmentVariables["REDIS_PASSWORD"] = redisPassword;
}) The password will get passed via an environment variable, and the call to |
The problem in your branch is that you are adding the redis command line options in separate args. The command/entrypoint being run is no longer the
The whole redis-server command + args needs to be passed on a single argument, which is the argument used for Take this example to illustrate what is wrong: When |
The Redis resource doesn't allow setting a password today, and this carries forward to deployment time too, i.e. Redis containers published from an AppHost have no password set. The resources for PostgreSQL, MSSQL, etc. do allow setting a password and do so by default.
We should revisit the default status of the Redis resource. As changing defaults has compatibility implications, we might want to consider doing it in stages, e.g.:
The text was updated successfully, but these errors were encountered: