-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a condition so the anti-forgery check can be skipped in cases l…
…ike an API request
- Loading branch information
FrostyApeOne
authored and
FrostyApeOne
committed
Feb 18, 2025
1 parent
3ba0dbd
commit 3da1db0
Showing
2 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/DfE.CoreLibs.Security/Cypress/CypressAwareAntiForgeryOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace DfE.CoreLibs.Security.Cypress | ||
{ | ||
public class CypressAwareAntiForgeryOptions | ||
{ | ||
/// <summary> | ||
/// A function that, given the current <see cref="HttpContext"/>, | ||
/// returns <c>true</c> if antiforgery should be skipped, or <c>false</c> otherwise. | ||
/// </summary> | ||
public Func<HttpContext, bool> ShouldSkipAntiforgery { get; set; } | ||
= _ => false; // Default: never skip | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters