summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.ja.md16
-rw-r--r--README.md18
2 files changed, 33 insertions, 1 deletions
diff --git a/README.ja.md b/README.ja.md
index 255c1fb..9538f04 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -30,6 +30,18 @@
## セキュリティと認証の詳細
+### CSRF保護
+
+このプロキシには、悪意のある攻撃を防ぐためのCSRF(クロスサイトリクエストフォージェリ)保護が含まれています。これは`gorilla/csrf`ライブラリを使用して実装されています。
+
+ユーザーがフォームのあるページにアクセスすると、一意のCSRFトークンが生成され、フォームに埋め込まれます。フォームが送信されると、サーバーはトークンがユーザーのセッションに保存されているものと一致するかどうかを確認します。一致しない場合、リクエストは拒否されます。
+
+この保護はデフォルトで有効になっています。以下の環境変数を使用して設定できます。
+
+- `CSRF_SECRET_KEY`: CSRFトークンの署名に使用される、長くてランダムな秘密鍵。
+- `CSRF_TRUSTED_ORIGINS`: 信頼できるオリジンのカンマ区切りリスト。フロントエンドがプロキシと異なるドメインでホストされている場合は、フロントエンドのオリジンをこのリストに追加する必要があります。
+- `CSRF_SAME_SITE`: CSRFクッキーの`SameSite`属性。`lax`(デフォルト)、`strict`、または`none`に設定できます。`none`に設定した場合は、`ENV=production`も設定してセキュアなクッキーを有効にする必要があります。
+
### パスワードの暗号化
ユーザーのパスワードは、平文(プレーンテキスト)では一切保存されません。パスワード専用に設計された強力で適応性のあるハッシュ関数である **bcrypt** アルゴリズムを使用して、安全にハッシュ化されます。ユーザーがログインする際、入力されたパスワードはハッシュ化され、保存されているハッシュ値と比較されます。これにより、万が一データベースが侵害された場合でも、元のパスワードが漏洩するのを防ぎます。
@@ -359,3 +371,7 @@ Authorization: Bearer <access_token>
| `REGISTER` | `false`に設定すると、新規ユーザー登録を無効にします。 | `true` |
| `AUTH_PATH_*` | ログイン、管理者ページなどの内部URLをカスタマイズするための変数セット。 | 様々、例: `/login`|
| `AUTH_ASSETS_PATH` | 内部静的アセット(CSS, JS)を提供するためのURLパス。 | `/assets` |
+| `ENV` | ランタイム環境。セキュアなクッキーを有効にするには`production`に設定します。 | - |
+| `CSRF_SECRET_KEY` | **(必須)** CSRF保護のための長くてランダムな秘密鍵。 | - |
+| `CSRF_TRUSTED_ORIGINS` | CSRF保護のための信頼できるオリジンのカンマ区切りリスト。 | - |
+| `CSRF_SAME_SITE` | CSRFクッキーのSameSite属性。`lax`、`strict`、または`none`にすることができます。 | `lax` |
diff --git a/README.md b/README.md
index a99af8c..e6a541f 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,18 @@ This project aims to solve that by acting as a central authentication service. B
## Security and Authentication Details
+### CSRF Protection
+
+The proxy includes CSRF (Cross-Site Request Forgery) protection to prevent malicious attacks. This is implemented using the `gorilla/csrf` library.
+
+When a user visits a page with a form, a unique CSRF token is generated and embedded in the form. When the form is submitted, the server checks if the token matches the one stored in the user's session. If they don't match, the request is rejected.
+
+This protection is enabled by default. You can configure it using the following environment variables:
+
+- `CSRF_SECRET_KEY`: A long, random secret key used to sign the CSRF tokens.
+- `CSRF_TRUSTED_ORIGINS`: A comma-separated list of trusted origins. If your frontend is hosted on a different domain than the proxy, you must add the frontend's origin to this list.
+- `CSRF_SAME_SITE`: The `SameSite` attribute for the CSRF cookie. It can be set to `lax` (default), `strict`, or `none`. If you set it to `none`, you must also set `ENV=production` to enable secure cookies.
+
### Password Encryption
User passwords are never stored in plaintext. They are securely hashed using the **bcrypt** algorithm, a strong, adaptive hashing function designed specifically for passwords. When a user logs in, the provided password is
@@ -356,4 +368,8 @@ The `refresh_token` is a long-lived token that can be used to obtain a new acces
| `API_PATH` | The base path for API routes to be protected by `PROTECT_API`. | `/api/` |
| `REGISTER` | If set to `false`, disables new user registration. | `true` |
| `AUTH_PATH_*` | A set of variables to customize the internal URLs for login, admin, etc. | Various, e.g., `/login`|
-| `AUTH_ASSETS_PATH` | The URL path for serving internal static assets (CSS, JS). | `/assets` | \ No newline at end of file
+| `AUTH_ASSETS_PATH` | The URL path for serving internal static assets (CSS, JS). | `/assets` |
+| `ENV` | The runtime environment. Set to `production` to enable secure cookies. | - |
+| `CSRF_SECRET_KEY` | **(Required)** A long, random secret key for CSRF protection. | - |
+| `CSRF_TRUSTED_ORIGINS` | A comma-separated list of trusted origins for CSRF protection. | - |
+| `CSRF_SAME_SITE` | The SameSite attribute for the CSRF cookie. Can be `lax`, `strict`, or `none`. | `lax` | \ No newline at end of file