|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using JetBrains.Annotations; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
|
|
|
|
namespace Volo.Abp.AspNetCore.Mvc.AntiForgery |
|
|
|
@ -23,8 +24,34 @@ namespace Volo.Abp.AspNetCore.Mvc.AntiForgery |
|
|
|
/// </summary>
|
|
|
|
public bool AutoValidate { get; set; } = true; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A predicate to filter types to auto-validate.
|
|
|
|
/// Return true to select the type to validate.
|
|
|
|
/// Default: returns true for all given types.
|
|
|
|
/// </summary>
|
|
|
|
[NotNull] |
|
|
|
public Predicate<Type> AutoValidateFilter |
|
|
|
{ |
|
|
|
get => _autoValidateFilter; |
|
|
|
set => _autoValidateFilter = Check.NotNull(value, nameof(value)); |
|
|
|
} |
|
|
|
private Predicate<Type> _autoValidateFilter; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Default methods: "GET", "HEAD", "TRACE", "OPTIONS".
|
|
|
|
/// </summary>
|
|
|
|
[NotNull] |
|
|
|
public HashSet<string> AutoValidateIgnoredHttpMethods |
|
|
|
{ |
|
|
|
get => _autoValidateIgnoredHttpMethods; |
|
|
|
set => _autoValidateIgnoredHttpMethods = Check.NotNull(value, nameof(value)); |
|
|
|
} |
|
|
|
private HashSet<string> _autoValidateIgnoredHttpMethods; |
|
|
|
|
|
|
|
public AbpAntiForgeryOptions() |
|
|
|
{ |
|
|
|
AutoValidateFilter = type => true; |
|
|
|
|
|
|
|
TokenCookie = new CookieBuilder |
|
|
|
{ |
|
|
|
Name = "XSRF-TOKEN", |
|
|
|
@ -34,6 +61,8 @@ namespace Volo.Abp.AspNetCore.Mvc.AntiForgery |
|
|
|
}; |
|
|
|
|
|
|
|
AuthCookieSchemaName = "Identity.Application"; |
|
|
|
|
|
|
|
AutoValidateIgnoredHttpMethods = new HashSet<string> {"GET", "HEAD", "TRACE", "OPTIONS"}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|