How nosurf performs trusted origin checks
masternosurf uses a multi-layered approach to verify that non-safe HTTP requests are coming from a trusted origin. This is critical for preventing CSRF attacks.
Sec-Fetch-Siteheader: If a modern browser sends this header with the valuesame-origin, nosurf allows the request (subject to CSRF token verification).OriginorRefererheaders: IfSec-Fetch-Siteis missing or notsame-origin, nosurf compares the request'sOrigin(orRefererifOriginis missing) against the website's own origin.
Note on Origin Construction: Because TLS is often terminated at a load balancer, nosurf cannot always know if the site is running over HTTPS. By default, it assumes HTTPS. If your site uses HTTP, you must configure this manually using SetIsTLSFunc to avoid breakage.