CookieValidatePrincipalContext Class

Context object passed to the ICookieAuthenticationProvider method ValidatePrincipal.

Namespace
Microsoft.AspNetCore.Authentication.Cookies
Assemblies
  • Microsoft.AspNetCore.Authentication.Cookies

Syntax

public class CookieValidatePrincipalContext : BaseCookieContext
class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext

Constructors

CookieValidatePrincipalContext(Microsoft.AspNetCore.Http.HttpContext, Microsoft.AspNetCore.Authentication.AuthenticationTicket, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions)

Creates a new instance of the context object.

Arguments:ticket (Microsoft.AspNetCore.Authentication.AuthenticationTicket) – Contains the initial values for identity and extra data
public CookieValidatePrincipalContext(HttpContext context, AuthenticationTicket ticket, CookieAuthenticationOptions options)

Properties

Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext.Principal

Contains the claims principal arriving with the request. May be altered to change the details of the authenticated user.

Return type:System.Security.Claims.ClaimsPrincipal
public ClaimsPrincipal Principal { get; }
Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext.Properties

Contains the extra meta-data arriving with the request ticket. May be altered.

Return type:Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties
public AuthenticationProperties Properties { get; }
Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext.ShouldRenew

If true, the cookie will be renewed

Return type:System.Boolean
public bool ShouldRenew { get; set; }

Methods

RejectPrincipal()

Called to reject the incoming principal. This may be done if the application has determined the account is no longer active, and the request should be treated as if it was anonymous.

public void RejectPrincipal()
ReplacePrincipal(System.Security.Claims.ClaimsPrincipal)

Called to replace the claims principal. The supplied principal will replace the value of the Principal property, which determines the identity of the authenticated request.

Arguments:principal (System.Security.Claims.ClaimsPrincipal) – The System.Security.Claims.ClaimsPrincipal used as the replacement
public void ReplacePrincipal(ClaimsPrincipal principal)