Skip to content

Don't emit an antiforgery token on every page for signed-in users #1607

Open

Description

@BenjaminMichaelis

_Layout.cshtml calls Antiforgery.GetAndStoreTokens on every page for signed-in users, adding Set-Cookie and no-store/Pragma headers everywhere, and would leak a shared token if [OutputCache] is ever applied. Fetch the token lazily only where a script needs it. The layout and ReadingContext view component also each re-check SignInManager.IsSignedIn.

Found during review of #1267; intentionally kept out of that PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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