Registration form: text browsers without fetch metadata pass when sessionless; keep a challenge only while live
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d47f1d5e9d
commit
7bd26e9239
4 changed files with 119 additions and 5 deletions
|
|
@ -26,4 +26,16 @@ public static class RequestOriginGuard
|
|||
var fetchSite = request.Headers["Sec-Fetch-Site"];
|
||||
return fetchSite.Count == 1 && string.Equals(fetchSite[0], "same-origin", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For the no-script sign-up form only. Text browsers (Lynx, w3m, Links) send neither Origin nor Sec-Fetch-Site, so a
|
||||
/// request with neither is let through when it carries no Bifrost session cookie: there is no session to replace.
|
||||
/// Any Origin or Sec-Fetch-Site present is judged exactly as <see cref="Allows"/> judges it, and a headerless request
|
||||
/// that does carry a session cookie is refused.
|
||||
/// </summary>
|
||||
public static bool AllowsFormWithoutFetchMetadata(HttpRequest request, BifrostHostOptions host) =>
|
||||
Allows(request, host) ||
|
||||
(!request.Headers.ContainsKey("Origin") &&
|
||||
!request.Headers.ContainsKey("Sec-Fetch-Site") &&
|
||||
!request.Cookies.Keys.Any(name => name.StartsWith(BifrostCookies.Session, StringComparison.Ordinal)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue