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.

CookiePolicy middleware can't affect CookieAuthentication middleware #814

Closed
@analogrelay

Description

@analogrelay

Because the CookieAuthentication middleware does it's own cookie-writing manually (see https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication.Cookies/ChunkingCookieManager.cs), the CookiePolicy middleware can't affect it. This is easily seen by doing something like this in your Startup.cs

app.UseCookiePolicy(new CookiePolicyOptions()
{
    HttpOnly = HttpOnlyPolicy.Always
});

app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
    AuthenticationScheme = "MagicSignin",
    CookieHttpOnly = false,
    LoginPath = new PathString("/Account/Login"),
    AccessDeniedPath = new PathString("/Account/AccessDenied"),
    AutomaticAuthenticate = true,
    AutomaticChallenge = true
});

CookiePolicy works by replacing the IResponseCookiesFeature, but CookieAuth sets the header manually so it ignores the policy.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions