mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Redirect loop with Identity, SPA, and [Authorize] on Home/Index #545
Closed
opened 2025-08-09 17:16:42 +00:00 by fergalmoran
·
0 comments
No Branch/Tag Specified
master
rybrande/masterToSrc
pakrym/no-console-fb
release/2.2
pakrym/remove-obsole-api-usage
maestro/release/2.2
maestro/master
release/2.1
release/2.0
rybrande/MergeRelease21IntoDev
rel/2.0.0-extensions
angular-animations-example
fix-angular-material-publishing
rel/2.0.0-templates
httpwithstatetransfer-example
rel/2.0.0-preview2-templates
aspnet-webpack-react-2.x
angular4-prerender-data-example
version-1.x
angular2-lazy-loading-example
581-isomorphic-react-cookies-example
example-using-typescript-paths-for-494
v1.0.x
angular2-materialize-example
redux-typed-1-x
primeng-example
font-awesome-example
karma-testing-example
2.2.0
2.2.0-preview3
2.2.0-preview2
2.2.0-preview1
2.1.1
2.1.0
2.0.4
2.1.0-rc1-final
2.1.0-preview2-final
2.0.3
2.1.0-preview1-final
2.0.2
2.0.1
rel/2.0.0
rel/2.0.0-preview2
Labels
Clear labels
2 - Working
2 - Working
3 - Done
3 - Done
3 - Done
3 - Done
3 - Done
3 - Done
3 - Done
angular
angular
angular
angular
angular
bug
bug
bug
bug
bug
bug
bug
bug
bug
core
core
core
core
core
core
core
duplicate
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
external
external
P1
P1
P1
P1
P1
P1
P2
P2
P2
P2
P2
P2
P2
P2
P2
PRI: 1 - Required
react
react
task
task
up-for-grabs
up-for-grabs
up-for-grabs
waiting
waiting
waiting
waiting
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
fergalmoran
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github/JavaScriptServices#545
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jimsmart on 7/26/2017
Hi,
There is something cranky going on with MapSpaFallbackRoute (ASP.NET Core 1.1.2) when used with Identity (1.1.2), with a HomeController Index using the [Authorize] tag — which causes infinite redirects when Kestrel receives an HTTP HEAD command.
The problem goes away if I remove either the MapSpaFallbackRoute (not helpful: the app is a SPA), or if I remove the [Authorize] tag from the HomeController's Index method.
Note that the problem doesn't manifest with a common HTTP GET/POST, so it was particularly difficult to track down the exact cause/combination for this to manifest.
To reproduce:
Using VS create a new ASP.NET Core project with Identity (Individual User Accounts). Add Microsoft.AspNetCore.SpaServices (1.1.1), wait for restore to complete.
Modify Startup.cs to add appropriate routes.MapSpaFallbackRoute call:-
Modify HomeController.cs to require auth on Index:-
Start the project
dotnet runFrom a terminal, run:
The output will be something like:
All is good.
Now run:
See the redirect loop:
If you move the [Authorize] tag to e.g. About() instead, and change the urls in the curl command, everything works fine: single redirects as expected.
If you remove the call to MapSpaFallbackRoute in Startup.cs, everything works fine: single redirects as expected.
But the combination of [Authorize] on HomeController.Index() and the call to MapSpaFallbackRoute manifests the problem.
We're actually seeing this in the wild — we have a SPA app served via Home/Index, on a site that requires auth on all pages, and some machines in the office simply get a 'too many redirects' error when trying to even access the login page (which should have no redirects). I've no idea why they're issuing a HEAD command (or indeed if they actually are? I suspect the same problem manifests in other ways also, just not with a simple GET/POST/etc) — but I've finally reproduced the infinite redirect on a dev machine with a simple configuration and trigger. (I'm sure you can imagine how long this may have taken me to pin down!?)
FWIW, the server log for the bad case is:
To my less knowledgeable mind, it's like some middlewear is kicking in when it shouldn't, but IDK.
Is there something we are missing? Or is this combination of Identity, SpaServices and [Authorize] on HomeController.Index just subtly broken for anything beyond GET/POST?
Perhaps this bug report belongs with Identity? Or Kestrel? (No end of googling sheds any light on the matter)
— Is there a workaround?
Obviously we have no control over whatever it is these few browsers are doing — FWIW, the app is over HTTPS (despite this repro not using it at all) so I'm fairly sure it's not firewalls/antivirus/proxies.
Obviously(?) we can't remove the MapSpaFallbackRoute (or can we? Suggestions for routing workarounds are most welcome!)
And we don't particularly want to serve the app from anything but the root url — and the app/homepage must require authentication.