| Did you know ... | Search Documentation: |
| csrf.pl -- Protect against cross-site request forgery |
Handlers that change state on behalf of a logged in user call
csrf_check/1 before doing anything. We do not use tokens, but verify the
request was initiated from our own site. Modern browsers send the
Sec-Fetch-Site header, which cannot be set by scripts. For browsers
that do not, we fall back to the Origin or Referer header.
Requests without any of these headers are refused. Note that this
implies that state-changing links cannot be used from bookmarks or
mail, as browsers send Sec-Fetch-Site: none for these.
csrf_check(+Request) is det
csrf_check(+Request, +Options) is dettrue (default false), also accept requests that were
not initiated from a web page: requests without any of the
headers above (e.g., from curl) and requests for which the
browser sends Sec-Fetch-Site: none (typed URL or
bookmark). Requests initiated from another site are still
refused. This is intended for handlers that are protected
by HTTP authentication, which browsers send along with
cross-site requests.