Skip to content

Commit 38486b6

Browse files
committed
Add some more explanation to the README
1 parent ad7ecab commit 38486b6

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This Rack middleware provides CSRF protection using the Sec-Fetch-Site header. It is inspired by Go's `http.CrossOriginProtection` which was introduced in Go 1.25. You can read about it [in this article](https://www.alexedwards.net/blog/preventing-csrf-in-go) and find more information about the `Sec-Fetch-Site` header [on MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Sec-Fetch-Site).
44

5+
The middleware blocks cross-origin state-changing requests (POST, PUT, PATCH, DELETE) by first checking the `Sec-Fetch-Site` header, which is available in all modern browsers, and rejecting requests where the value is not `same-origin` or `none`. For older browsers that don't send `Sec-Fetch-Site`, it falls back to comparing the `Origin` header against the `Host` header, ensuring that only requests from the same origin can modify state. Safe methods (GET, HEAD, OPTIONS) are always allowed through, and requests without an `Origin` header are treated as same-origin to support non-browser clients.
6+
57
## Installation
68

79
Add this line to your application's Gemfile:

0 commit comments

Comments
 (0)