Skip to content

Conversation

@HaoK
Copy link
Member

@HaoK HaoK commented Apr 7, 2022

For #40964

@ghost ghost added the area-dataprotection Includes: DataProtection label Apr 7, 2022
@HaoK
Copy link
Member Author

HaoK commented Apr 11, 2022

Thoughts @blowdart we will just trim a single either direction slash by default

@blowdart
Copy link
Contributor

Is that not going to end up with a null discriminator in some circumstances? That feels bad.

@HaoK
Copy link
Member Author

HaoK commented Apr 11, 2022

You mean if a single "/" is the content root? Trim would return empty string right?

@blowdart
Copy link
Contributor

Yup. That feels odd to me.

@HaoK
Copy link
Member Author

HaoK commented Apr 11, 2022

But does that matter? This is just to disambugiate apps, in practice people wouldn't have an app that's "/" and an app thats "" right? As long as we don't generate collisions between real distinct apps, this is an implementation detail, especially since this is just when the content root path is used as opposed to using an explicitly set application name

@blowdart
Copy link
Contributor

I guess, it's just an empty discriminator feels wrong somehow.

@HaoK HaoK marked this pull request as ready for review April 19, 2022 17:18
@HaoK HaoK requested a review from Pilchie as a code owner April 19, 2022 17:18

public string? Discriminator => _hosting?.ContentRootPath;
// Note: ContentRootPath behavior depends on the version, sometimes it has a trailing slash, we normalize by default by removing a trailing slash
public string? Discriminator => _hosting?.ContentRootPath?.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
Copy link
Member

Choose a reason for hiding this comment

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

Should it be stored in a field at construction instead of computed of every invocation?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't know how IHostEnvironment implements ContentRootPath right? Seems like the caching would belong there

Co-authored-by: Aditya Mandaleeka <[email protected]>
@Tratcher
Copy link
Member

Assuming this is backported to 6, does this mean we'll now have consistent behavior across 5, 6, and 7 regardless of the entry point APIs?

@HaoK
Copy link
Member Author

HaoK commented Apr 19, 2022

That's the point, but I'm not even sure we need this to be backported to 6 for compat, since I think its only in 7 that we have the mismatch between trailing slash and no slash.

@Tratcher
Copy link
Member

Tratcher commented Apr 19, 2022

There was a similar break in 6 so it's not compatible with 7, even after this change in 7.

@HaoK
Copy link
Member Author

HaoK commented Apr 19, 2022

Which direction do you mean? In 7 it will handle either situation, since it will trim, we don't care about 7.0 cookies going to 6 as much do we?

@Tratcher
Copy link
Member

We want cookies to be forwards and backwards compatible where possible. Cookies from 6 are currently neither. I think this fix makes 5 and 7 compatible, but we'd still have to fix 6.

@HaoK
Copy link
Member Author

HaoK commented Apr 20, 2022

Cookies from 6 are currently neither

I don't think this is generally true, I believe the only apps that were affected were the new minimal style that hit the difference in content root, so it would be very hard for them to in practice have compat issues going backwards to 5. Going forward to 7 won't have an issue after this fix. But whatever, this is a cheap fix to backport to 6.0 anyways so I guess it doesn't matter

@HaoK HaoK merged commit cf513d3 into main Apr 21, 2022
@HaoK HaoK deleted the haok/disc branch April 21, 2022 20:58
@ghost ghost added this to the 7.0-preview5 milestone Apr 21, 2022
@HaoK
Copy link
Member Author

HaoK commented Apr 21, 2022

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/2204307835

@github-actions
Copy link
Contributor

@HaoK backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Normalize data protection app discriminator
Using index info to reconstruct a base tree...
M	src/DataProtection/DataProtection/src/Internal/HostingApplicationDiscriminator.cs
M	src/DataProtection/DataProtection/test/HostingTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/DataProtection/DataProtection/test/HostingTests.cs
CONFLICT (content): Merge conflict in src/DataProtection/DataProtection/test/HostingTests.cs
Auto-merging src/DataProtection/DataProtection/src/Internal/HostingApplicationDiscriminator.cs
CONFLICT (content): Merge conflict in src/DataProtection/DataProtection/src/Internal/HostingApplicationDiscriminator.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Normalize data protection app discriminator
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-dataprotection Includes: DataProtection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants