Skip to content

Commit ffbdd85

Browse files
Adds request signing and key publishing for downstream verification (#76)
1 parent 868d31a commit ffbdd85

File tree

17 files changed

+1948
-3
lines changed

17 files changed

+1948
-3
lines changed

Cargo.lock

Lines changed: 377 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ chrono = "0.4.42"
2424
config = "0.15.18"
2525
cookie = "0.18.1"
2626
derive_more = { version = "2.0", features = ["display", "error"] }
27+
ed25519-dalek = { version = "2.1", features = ["rand_core"] }
2728
error-stack = "0.6"
2829
fastly = "0.11.9"
2930
fern = "0.7.1"
@@ -38,6 +39,8 @@ log-fastly = "0.11.9"
3839
lol_html = "2.7.0"
3940
pin-project-lite = "0.2"
4041
regex = "1.12.2"
42+
jose-jwk = "0.1.2"
43+
rand = "0.8"
4144
serde = { version = "1.0", features = ["derive"] }
4245
serde_json = "1.0.145"
4346
sha2 = "0.10.9"

README.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ git clone [email protected]:IABTechLab/trusted-server.git
104104

105105
### Configure
106106
#### Edit configuration files
107-
:information_source: Note that youll have to edit the following files for your setup:
107+
:information_source: Note that you'll have to edit the following files for your setup:
108108

109-
- fastly.toml (service ID, author, description)
110-
- trusted-server.toml (KV store ID names - optional)
109+
- fastly.toml (service ID, author, description, Config/Secret Store IDs for request signing)
110+
- trusted-server.toml (KV store ID names - optional, request signing configuration)
111111

112112
### Build
113113

@@ -153,6 +153,47 @@ cargo test
153153
- `cargo check`: Ensure compilation succeeds on Linux, MacOS, Windows and WebAssembly
154154
- `cargo bench`: Run all benchmarks
155155

156+
## Request Signing
157+
158+
Trusted Server supports cryptographic signing of OpenRTB requests and other API calls using Ed25519 keys.
159+
160+
### Configuration
161+
162+
Request signing requires Fastly Config Store and Secret Store for key management:
163+
164+
1. **Create Fastly Stores** (via Fastly Control Panel or CLI):
165+
- Config Store: `jwks_store` - stores public keys (JWKs) and key metadata
166+
- Secret Store: `signing_keys` - stores private signing keys
167+
168+
2. **Configure in trusted-server.toml**:
169+
```toml
170+
[request_signing]
171+
enabled = true # Set to true to enable request signing
172+
config_store_id = "<your-fastly-config-store-id>" # Config Store ID from Fastly
173+
secret_store_id = "<your-fastly-secret-store-id>" # Secret Store ID from Fastly
174+
```
175+
176+
### Key Management Endpoints
177+
178+
Once configured, the following endpoints are available:
179+
180+
- **`GET /.well-known/ts.jwks.json`**: Returns active public keys in JWKS format for signature verification
181+
- **`POST /verify-signature`**: Verifies a signature against a payload and key ID (useful for testing)
182+
- Request body: `{"payload": "...", "signature": "...", "kid": "..."}`
183+
- Response: `{"verified": true/false, "kid": "...", "message": "..."}`
184+
185+
#### Admin Endpoints (Key Rotation)
186+
187+
- **`POST /admin/keys/rotate`**: Generates and activates a new signing key
188+
- Optional body: `{"kid": "custom-key-id"}` (auto-generates date-based ID if omitted)
189+
- Response includes new key ID, previous key ID, and active keys list
190+
191+
- **`POST /admin/keys/deactivate`**: Deactivates or deletes a key
192+
- Request body: `{"kid": "key-to-deactivate", "delete": false}`
193+
- Set `delete: true` to permanently remove the key (also deactivates it)
194+
195+
:warning: Key rotation keeps both the new and previous key active to allow for graceful transitions. Deactivate old keys manually when no longer needed.
196+
156197
## First-Party Endpoints
157198

158199
- `/first-party/ad` (GET): returns HTML for a single slot (`slot`, `w`, `h` query params). The server inspects returned creative HTML and rewrites:

crates/common/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ handlebars = { workspace = true }
2525
hex = { workspace = true }
2626
hmac = { workspace = true }
2727
http = { workspace = true }
28+
jose-jwk = { workspace = true }
2829
log = { workspace = true }
30+
rand = { workspace = true }
2931
log-fastly = { workspace = true }
3032
lol_html = { workspace = true }
3133
pin-project-lite = { workspace = true }
@@ -39,6 +41,7 @@ url = { workspace = true }
3941
urlencoding = { workspace = true }
4042
uuid = { workspace = true }
4143
validator = { workspace = true }
44+
ed25519-dalek = { workspace = true }
4245

4346
[build-dependencies]
4447
config = { workspace = true }

0 commit comments

Comments
 (0)