Skip to content
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

Add Password To Redis #4642

Merged
merged 29 commits into from
Jan 31, 2025
Merged

Add Password To Redis #4642

merged 29 commits into from
Jan 31, 2025

Conversation

Alirexaa
Copy link
Contributor

@Alirexaa Alirexaa commented Jun 25, 2024

close: #3838

Microsoft Reviewers: Open in CodeFlow

@Alirexaa Alirexaa requested a review from mitchdenny as a code owner June 25, 2024 13:12
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-integrations Issues pertaining to Aspire Integrations packages label Jun 25, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 25, 2024
.WithImage(RedisContainerImageTags.Image, RedisContainerImageTags.Tag)
.WithImageRegistry(RedisContainerImageTags.Registry);
}
throw new InvalidOperationException();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a message to this exception to explain what went wrong?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a shame that we have to do these parameters in this order (its different to AddPostgres).

@mitchdenny mitchdenny added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Jun 26, 2024
@mitchdenny
Copy link
Member

I'm comfortable with this change pending @eerhardt 's comments about the API txt files and some incremental improvements to the XML docs since we are in the neighbhorhood.

I'm a little disappointed that about the parameter ordering but I can't think of a way that isn't a binary/source breaking change that isn't also disruptive.

One more iteration and we should be able to stamp an approval on this. Thanks once again for your efforts @Alirexaa.

@mitchdenny mitchdenny self-assigned this Jun 26, 2024
@mitchdenny mitchdenny added this to the 8.1 milestone Jun 26, 2024
@Alirexaa Alirexaa requested a review from mitchdenny June 27, 2024 20:21
@radical
Copy link
Member

radical commented Jun 28, 2024

Some of my comments might be non-sensical, or could be addressed in a follow-up PR. I'll let others decide that, since I'm very new to this code:)

ReferenceExpression.Create(
$"{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");
$"{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)},password={PasswordParameter}")
Copy link
Member

@DamianEdwards DamianEdwards Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the password need to be encoded here, e.g. URI encoded?
It likely does but we shouldn't fix it here in isolation as this is a larger issue #3117

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReferenceExpression.Create(
$"{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");
$"{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)},password={PasswordParameter}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgravell
Copy link
Member

mgravell commented Jul 8, 2024

@eerhardt We've discussed this for the client a few times but it has never hit the top of the pile. If it is a blocker, we can prioritize. I would suggest looking at ado-net quoted values as the template, but obvs we'd need to think a little about how to do it without impacting existing use of any new token

@eerhardt
Copy link
Member

eerhardt commented Jul 8, 2024

@eerhardt We've discussed this for the client a few times but it has never hit the top of the pile. If it is a blocker, we can prioritize. I would suggest looking at ado-net quoted values as the template, but obvs we'd need to think a little about how to do it without impacting existing use of any new token

I don't think it is blocking this work. I just wanted to point out that we can't URL encode the connection string here.

@drewnoakes
Copy link
Member

@drewnoakes @adamint - is it possible to mark command line arguments as "secret"? So they get obfuscated in the dashboard.

#5065 tracks marking resource properties as secrets, however that has to be specified by the resource service. We could hard-code some known properties as sensitive. If we did that, which would you think should be included? The current list is https://github.com/dotnet/aspire/blob/0f2931a94873d09e5a76f72485000e5388bf08dd/src/Shared/Model/KnownProperties.cs

This is in review in #5380

@mitchdenny
Copy link
Member

Yeah, I was wondering if it would make sense for us to switch from library/redis to redis/redis-stack-server instead. And then Add WithRedisInsight (dotnet/aspire#5227) would switch the image from redis/redis-stack-server to redis/redis-stack and add the appropriate endpoints.

I think this is an option we should seriously consider. I think we would just need to look through where there are any licensing implications for folks deploying that image into production. There might be extra licensing requirements that we wouldn't want to silently swap people into.

@Alirexaa Alirexaa mentioned this pull request Sep 5, 2024
16 tasks
@davidfowl davidfowl added the redis Issues related to redis integrations label Sep 14, 2024
@eerhardt
Copy link
Member

I've revived this PR with the latest code in main. The intent is to get this change into 9.1. The initial concerns that blocked this change should no longer be a problem. The command line args in the dashboard are hidden/masked by default now.

One complication is that Redis Insight needs to be initialized before we add a database with a password. I'll add a comment to the code to start a conversation about it there.

agreements = new
{
// all 4 are required to be set
eula = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unfortunate, but it is the only way I could get it to work. See RedisInsight/RedisInsight#3452 for more information on why this is needed.

Note that this isn't accepting the EULA (it is sending false). But the consequences of initializing this is the pop up no longer happens on first run of Redis Insight, which is a nice user experience.

Thoughts? @sebastienros @DamianEdwards @Alirexaa

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the options?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems they're suggesting we wait until they implement support for adding databases via environment variables instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened [Bug]: Posting eula: false to /api/settings suppresses the first run dialog (RedisInsight/RedisInsight#4340) for the first run dialog issue.

Let's move forward with this PR for now. We can readjust later.

@mgravell
Copy link
Member

mgravell commented Jan 29, 2025

Question: is it possible to specify the user for Redis? Or is that unnecessary in this scenario, with Aspire just using the default user? Similarly, there is increasing support for azure etc identity tokens for auth.


/// <summary>
/// Gets the parameter that contains the Redis server username.
/// </summary>
private ReferenceExpression ConnectionString =>
Copy link
Member

@davidfowl davidfowl Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Prefer this pattern

internal ReferenceExpression BuildConnectionString(string? databaseName = null)

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we mark this as a breaking change?

@eerhardt
Copy link
Member

is it possible to specify the user for Redis? Or is that unnecessary in this scenario, with Aspire just using the default user?

Right now, no. We are just adding password protection for now. If necessary, we can also add support for user in the future.

Similarly, there is increasing support for azure etc identity tokens for auth.

We support Azure Redis and Entra ID already in 9.0. See https://learn.microsoft.com/dotnet/aspire/caching/stackexchange-redis-integration#add-azure-cache-for-redis-client

@eerhardt
Copy link
Member

Do we mark this as a breaking change?

I don't think this is a breaking change. We can log it in the changelog, but I'm not sure exactly what it would break. The only thing I can think of is if someone is explicitly cutting the password out of the connection string getting flown to the app (or passing the connection string a custom way - not using our Hosting ConnectionString).

@eerhardt eerhardt merged commit 7d221ef into dotnet:main Jan 31, 2025
9 checks passed
@Alirexaa Alirexaa deleted the RedisPasswordOptions branch January 31, 2025 21:31
@eerhardt
Copy link
Member

Thank you, @Alirexaa for your continued contributions!

eerhardt added a commit to eerhardt/aspire that referenced this pull request Jan 31, 2025
Repond to feedback from dotnet#4642. Refactor how the connection string reference expression is built.
eerhardt added a commit that referenced this pull request Feb 1, 2025
Repond to feedback from #4642. Refactor how the connection string reference expression is built.
eerhardt added a commit to eerhardt/aspire that referenced this pull request Feb 10, 2025
@eerhardt eerhardt mentioned this pull request Feb 10, 2025
5 tasks
eerhardt added a commit that referenced this pull request Feb 11, 2025
* Revert "Follow up from Redis Password change (#7356)"

This reverts commit ac76241.

* Revert "Add Password To Redis (#4642)"

This reverts commit 7d221ef.

* Remove unnecessary using

* Revert unnecessary changes
@Alirexaa Alirexaa mentioned this pull request Feb 13, 2025
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. community-contribution Indicates that the PR has been added by a community member redis Issues related to redis integrations security 🔐
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revisit Redis password options
10 participants