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

Automatic Cookies challenge overridden by Windows Authentication since 1.1.0 #1057

Closed
@c-s-n

Description

@c-s-n

Background

I use the IISIntegration with IISOptions.AutomaticAuthentication = true and IISOptions.ForwardWindowsAuthentication = true. Furthermore I use the Cookie Authentication (without Identity) with CookieAuthenticationOptions.AutomaticAuthenticate = true and CookieAuthenticationOptions.AutomaticChallenge = true. This should be fine in combination (see e.g. also this comment). Since ASP.NET Core 1.1.0, most likely down to #930 and #982, this doesn't challenge any more as expected.

Functional impact

When a not yet authenticated user accesses a controller with an authorization policy applied that requires an authenticated user, but no explicit authentication schemes, since 1.1.0 the Windows Authentication always ignores the challenge from the Cookies Authentication. Thus a 401 is returned instead of the user being redirected to the login page.

Minimal repro steps

I haven't setup yet a small project for reproduction, but in our project that used to work like expected (see below) with ASP.NET Core 1.0.0/1.0.1, and which was now upgraded to 1.1.0 (all dependencies and tools), the expected and actual result can be switched by changing only the "Microsoft.AspNetCore.Authentication.Cookies" package (with its dependent "Microsoft.AspNetCore.Authentication") from/to version 1.1.0 resp. 1.0.0.

Expected result

Following - actually expected behavior - used to happen pre 1.1.0:

  • Authorization failed for user: (null).
  • Executing ChallengeResult with authentication schemes ().
  • AuthenticationScheme: Cookies was challenged.
  • CookieAuthenticationEvents.OnRedirectToLogin gets called once and redirects to the CookieAuthenticationOptions.LoginPath
  • Response is 302
  • Login page is shown

Actual result

What does happen since 1.1.0:

  • Authorization failed for user: (null).
  • Executing ChallengeResult with authentication schemes ().
  • AuthenticationScheme: Cookies was challenged.
  • CookieAuthenticationEvents.OnRedirectToLogin gets called and calls context.Response.Redirect
  • Response is 401 though
  • Same page/path is requested again by the browser
  • Above sequence happens again!
  • After 401 is returned the second time, the browser's Windows Auth popup is shown

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions