Skip to content

Commit b3f736c

Browse files
refactor: rename cookie_secret to signing_key and add JWT test coverage
Breaking changes: - Rename cookie_secret -> signing_key for clarity (JWT signing key) - Remove redundant CookieGenerator.Secret field (unused) Improvements: - Fix Content-Type matching: use HasPrefix + ToLower for RFC compliance - Now handles: application/x-www-form-urlencoded; charset=UTF-8 - Case-insensitive: Application/X-WWW-Form-URLEncoded - Add comprehensive JWT test coverage (20 tests): - Signature verification and tampering detection - Expiration validation - Token lifecycle and status transitions - Cookie generation and validation - Edge cases and malformed tokens Updated: - README: cookie_secret -> signing_key with JWT clarification - Config example: updated to use signing_key - Simplified CookieGenerator.Init() (no secret param) All tests pass. Closes security and UX gaps in stateless captcha flow.
1 parent 2a63ef0 commit b3f736c

File tree

5 files changed

+482
-26
lines changed

5 files changed

+482
-26
lines changed

config/crowdsec-spoa-bouncer.yaml.local

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ hosts:
2323
secret_key: 0x90acf418F0A70371f2F828C30A16526e28876075
2424
site_key: 7b50120d-ed3e-4e1d-8913-d832f4d769d3
2525
provider: hcaptcha
26-
cookie_secret: "your-32-byte-minimum-secret-key-for-cookie-signing-here" # REQUIRED in 0.3.0: minimum 32 bytes
27-
session_idle_timeout: 5m
28-
session_max_time: 30m
26+
signing_key: "your-32-byte-minimum-secret-key-for-jwt-signing-here" # REQUIRED in 0.3.0: minimum 32 bytes for HMAC-SHA256
2927
ban:
3028
contact_us_url: "mailto:support@crowdsec.net"
3129
appsec:

internal/remediation/captcha/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ hosts:
1414
timeout: 10 # HTTP client timeout in seconds (default: 5)
1515
pending_ttl: "30m" # TTL for pending captcha tokens (default: 30m)
1616
passed_ttl: "24h" # TTL for passed captcha tokens (default: 24h)
17-
cookie_secret: "your-32-byte-minimum-secret-key-here" # REQUIRED: Secret for signing cookies (minimum 32 bytes) - breaking change in 0.3.0
17+
signing_key: "your-32-byte-minimum-secret-key-here" # REQUIRED: Key for signing JWT tokens (minimum 32 bytes) - breaking change in 0.3.0
1818
- host: "*"
1919
captcha:
2020
fallback_remediation: allow
@@ -28,7 +28,7 @@ hosts:
2828
- `timeout` - HTTP client timeout in seconds for captcha validation requests (default: 5)
2929
- `pending_ttl` - Time-to-live for pending captcha tokens. Accepts Go duration format (e.g., "30m", "1h", "2h30m"). Default: "30m"
3030
- `passed_ttl` - Time-to-live for passed captcha tokens. Accepts Go duration format (e.g., "24h", "48h", "7d"). Default: "24h"
31-
- `cookie_secret` - **REQUIRED** (breaking change in 0.3.0): Secret key used for signing captcha cookies. Must be at least 32 bytes. This must be explicitly configured and should be different from `secret_key` for compliance and security best practices. For multi-instance deployments, use the same `cookie_secret` across all instances to share cookies.
31+
- `signing_key` - **REQUIRED** (breaking change in 0.3.0): Cryptographic key used for signing JWT captcha tokens (HMAC-SHA256). Must be at least 32 bytes. This must be explicitly configured and should be different from `secret_key` for compliance and security best practices. For multi-instance deployments, use the same `signing_key` across all instances to share tokens.
3232

3333
To generate a secure random 32-byte secret using OpenSSL:
3434
```bash

0 commit comments

Comments
 (0)