Add the cookie IsEssential flag and feature
This commit is contained in:
parent
9aaaefbb1b
commit
ac702f6818
|
|
@ -72,6 +72,12 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// </summary>
|
||||
public virtual TimeSpan? MaxAge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this cookie is essential for the application to function correctly. If true then
|
||||
/// consent policy checks may be bypassed. The default value is false.
|
||||
/// </summary>
|
||||
public virtual bool IsEssential { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates the cookie options from the given <paramref name="context"/>.
|
||||
/// </summary>
|
||||
|
|
@ -99,6 +105,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
HttpOnly = HttpOnly,
|
||||
MaxAge = MaxAge,
|
||||
Domain = Domain,
|
||||
IsEssential = IsEssential,
|
||||
Secure = SecurePolicy == CookieSecurePolicy.Always || (SecurePolicy == CookieSecurePolicy.SameAsRequest && context.Request.IsHttps),
|
||||
Expires = Expiration.HasValue ? expiresFrom.Add(Expiration.Value) : default(DateTimeOffset?)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,5 +59,11 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// </summary>
|
||||
/// <returns>The max-age date and time for the cookie.</returns>
|
||||
public TimeSpan? MaxAge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this cookie is essential for the application to function correctly. If true then
|
||||
/// consent policy checks may be bypassed. The default value is false.
|
||||
/// </summary>
|
||||
public bool IsEssential { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Http.Features
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to query, grant, and withdraw user consent regarding the storage of user
|
||||
/// information related to site activity and functionality.
|
||||
/// </summary>
|
||||
public interface ITrackingConsentFeature
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates if consent is required for the given request.
|
||||
/// </summary>
|
||||
bool IsConsentNeeded { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if consent was given.
|
||||
/// </summary>
|
||||
bool HasConsent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates either if consent has been given or if consent is not required.
|
||||
/// </summary>
|
||||
bool CanTrack { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Grants consent for this request. If the response has not yet started then
|
||||
/// this will also grant consent for future requests.
|
||||
/// </summary>
|
||||
void GrantConsent();
|
||||
|
||||
/// <summary>
|
||||
/// Withdraws consent for this request. If the response has not yet started then
|
||||
/// this will also withdraw consent for future requests.
|
||||
/// </summary>
|
||||
void WithdrawConsent();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue