Open v-elenafeng opened 7 months ago
@v-elenafeng I believe this is the issue you're calling out - if you try to navigate to http://localhost:xxxx/weatherforecast, it doesn't automatically re-direct you to the corresponding https address https://localhost:xxxx/weatherforecast. I believe this is the same behavior in other ASP.NET Core API or web apps without aspire too. Can you confirm?
Note: I believe if you navigate to the root of the apiservice http://localhost:xxxx, then it will re-direct successfully to https://localhost:xxxx.
@balachir Works for ASP.NET Core Web API - can re-direct to https address https://localhost:xxxx/weatherforecast when clicking on http://localhost:xxxx/weatherforecast.
The cause of this issue for Aspire Starter App is the lack of app.UseHttpsRedirection(); in Program.cs of apiservice. After adding the code will not reproduce this issue.
@DamianEdwards @davidfowl does this need to be fixed in the template for Preview 6?
I think so yeah
During security review it was remarked by @blowdart that the API project shouldn't have HTTPS redirect enabled, but indeed the usual API templates do have it. I'm OK with adding it to the API project in the Aspire Starter template unless there's a forcing security related reason to exclude it.
The reason why I don't want redirection in API projects is that API projects should only listen on HTTPs - if an authenticated HTTP request is made, it's too late to redirect at that point, the token may have been captured. (That old attack on twitter via open wifi networks was like this).
Yes, it's unlikely but sending auth over http is forbidden by our standards.
The right fix, in my eyes, would be to remove it from the normal templates 😈
That would break on linux automatically. That's outside of the scope of aspire at this point. If we want to make a change like that, we should discuss making it to asp.net core in general and we should deal with the fallout.
It doesn't seem like any change here is within scope for Aspire GA at this point. Move this to 8.1?
Moving out of 8.1 as I don't think there's anything actionable in Aspire here still.
INSTALL STEPS
Clean machine: Win11 x64 23h2 ENU
Install VS 17.10 Preview 3 FB
REPRO STEPS
New Project > .NET Aspire Starter Application > .NET 8.0
Build the solution and run with https
On the Dashboard, open the apiservice endpoint "http://localhost:xxxx/weatherforecast"
ACTUAL The launch URL is localhost:xxxx not https://localhost:xxxx
Note:
EXPECTED The launch URL is always https://localhost:xxxx when run with https