Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Map causes wrong ReturnUrl parameter for Cookies #1730

Closed
Tratcher opened this issue Apr 17, 2018 · 2 comments
Closed

Map causes wrong ReturnUrl parameter for Cookies #1730

Tratcher opened this issue Apr 17, 2018 · 2 comments
Labels
bug cost: XS Will take about half a day to complete
Milestone

Comments

@Tratcher
Copy link
Member

            app.UseAuthentication();

            app.Map("/hello", map =>
            {
                map.Run(async context =>
                {
                    if (!context.User.Identities.Any(identity => identity.IsAuthenticated))
                    {
                        await context.ChallengeAsync();
                        return;
                    }

                    context.Response.ContentType = "text/plain";
                    await context.Response.WriteAsync("Hello old timer");
                });
            });

If UseAuthentication is outside of the Map, and ChallengeAsync is called inside the Map, then CookieAuth generates the wrong ReturnUrl parameter.

redirectUri = OriginalPathBase + Request.Path + Request.QueryString;

In the example http://localhost:12345/hello/world?query, it uses the OriginalPathBase (empty) but the current request Path "/world" and redirects to "/world?query". It should use the OriginalPathBase "" and the OriginalPath "/hello/world" rather than the current Path.

@Tratcher Tratcher added bug cost: XS Will take about half a day to complete labels Apr 17, 2018
@muratg muratg added this to the 2.2.0 milestone Apr 19, 2018
@muratg
Copy link
Contributor

muratg commented Apr 19, 2018

Workaround:

                    await context.ChallengeAsync(new AuthenticationProperties()
                    {
                        // https://github.com/aspnet/Security/issues/1730
                        // Return here after authenticating
                        RedirectUri = context.Request.PathBase + context.Request.Path + context.Request.QueryString
                    });

@Eilon
Copy link
Contributor

Eilon commented Sep 6, 2018

Won't Fix because there is not enough demand for this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug cost: XS Will take about half a day to complete
Projects
None yet
Development

No branches or pull requests

3 participants