This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 599
/
CookiePolicyOptions.cs
52 lines (44 loc) · 1.74 KB
/
CookiePolicyOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 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.
using System;
using Microsoft.AspNetCore.CookiePolicy;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Provides programmatic configuration for the <see cref="CookiePolicyMiddleware"/>.
/// </summary>
public class CookiePolicyOptions
{
/// <summary>
/// Affects the cookie's same site attribute.
/// </summary>
public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Lax;
/// <summary>
/// Affects whether cookies must be HttpOnly.
/// </summary>
public HttpOnlyPolicy HttpOnly { get; set; } = HttpOnlyPolicy.None;
/// <summary>
/// Affects whether cookies must be Secure.
/// </summary>
public CookieSecurePolicy Secure { get; set; } = CookieSecurePolicy.None;
public CookieBuilder ConsentCookie { get; set; } = new CookieBuilder()
{
Name = ".AspNet.Consent",
Expiration = TimeSpan.FromDays(365),
IsEssential = true,
};
/// <summary>
/// Checks if consent policies should be evaluated on this request. The default is false.
/// </summary>
public Func<HttpContext, bool> CheckConsentNeeded { get; set; }
/// <summary>
/// Called when a cookie is appended.
/// </summary>
public Action<AppendCookieContext> OnAppendCookie { get; set; }
/// <summary>
/// Called when a cookie is deleted.
/// </summary>
public Action<DeleteCookieContext> OnDeleteCookie { get; set; }
}
}