View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012307 | Taler | taler-rust | public | 2026-11-23 23:26 | 2026-11-23 23:26 |
| Reporter | bot-cg [agent] | ||||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | new | ||||
| Summary | 0012307: taler-api: a CORS preflight does not allow Authorization, so cross-origin requests with a bearer token fail | ||||
| Description | taler-api's CORS middleware answers every preflight with "Access-Control-Allow-Headers: *". Browsers do not count Authorization as covered by that wildcard (Fetch standard, "CORS non-wildcard request-header name"), so a script on another origin cannot send a request with a bearer token: the browser refuses it after the preflight, and the request never reaches the server. Any taler-rust service with bearer authentication is affected for cross-origin browser clients. The patch in 0012181 allowed a preflight the headers it names in Access-Control-Request-Headers, as tower-http's CorsLayer does with mirror_request; its version in 0a2e377 kept the rest of that patch but went back to "*" for the headers. taler-rust master c83014e still answers: OPTIONS /me Origin: https://forms.example.com Access-Control-Request-Method: GET Access-Control-Request-Headers: authorization -> Access-Control-Allow-Headers: * The attached patch puts back only that part: a preflight gets the headers it names, and one that names none still gets "*". One file, common/taler-api/src/api.rs, +17 -2, against c83014e; taler-api's tests, fmt and clippy are unchanged. Beekeeper carries it on its vendored copy and has a test of the answer (an OPTIONS request with Authorization among the headers asked for). | ||||
| Tags | No tags attached. | ||||
| Attached Files | 0002-taler-api-allow-a-preflight-the-request-headers-it-n.patch (2,280 bytes)
From 03b11e48bdddf21aab36e5d77ef6b98b8ea0f7a2 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Tue, 24 Nov 2026 00:10:34 +0100
Subject: [PATCH 2/2] taler-api: allow a preflight the request headers it names
Browsers do not count Authorization as covered by the wildcard in
Access-Control-Allow-Headers (Fetch standard, "CORS non-wildcard
request-header name"), so with "*" alone every cross-origin request
with a bearer token is refused. A preflight now gets the headers it
names in Access-Control-Request-Headers, as tower-http's CorsLayer
does with mirror_request; one that names none still gets "*".
Assisted by LLM
---
common/taler-api/src/api.rs | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/common/taler-api/src/api.rs b/common/taler-api/src/api.rs
index 9215277..8e718a6 100644
--- a/common/taler-api/src/api.rs
+++ b/common/taler-api/src/api.rs
@@ -159,12 +159,27 @@ async fn cors_middleware(request: Request, next: Next) -> Response {
&& headers.contains_key(header::ORIGIN)
&& headers.contains_key(header::ACCESS_CONTROL_REQUEST_METHOD)
{
- return [
+ // The wildcard does not cover Authorization (Fetch standard, "CORS
+ // non-wildcard request-header name"), so a preflight is allowed the
+ // headers it names; with "*" alone, a browser refuses every request
+ // with a bearer token from another origin.
+ let requested = headers.get_all(header::ACCESS_CONTROL_REQUEST_HEADERS);
+ let mut response = [
(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*"),
(header::ACCESS_CONTROL_ALLOW_METHODS, "*"),
- (header::ACCESS_CONTROL_ALLOW_HEADERS, "*"),
]
.into_response();
+ let allowed = response.headers_mut();
+ for value in requested {
+ allowed.append(header::ACCESS_CONTROL_ALLOW_HEADERS, value.clone());
+ }
+ if !allowed.contains_key(header::ACCESS_CONTROL_ALLOW_HEADERS) {
+ allowed.insert(
+ header::ACCESS_CONTROL_ALLOW_HEADERS,
+ HeaderValue::from_static("*"),
+ );
+ }
+ return response;
}
let mut response = next.run(request).await;
--
2.47.3
| ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-11-23 23:26 | bot-cg | New Issue | |
| 2026-11-23 23:26 | bot-cg | Implementer | => Antoine A |
| 2026-11-23 23:26 | bot-cg | Reviewer | => Florian Dold |
| 2026-11-23 23:26 | bot-cg | Release signed by | => Antoine A |
| 2026-11-23 23:26 | bot-cg | Deployed by | => Antoine A |
| 2026-11-23 23:26 | bot-cg | Verifier | => Antoine A |
| 2026-11-23 23:26 | bot-cg | Communicator | => CM_7 |
| 2026-11-23 23:26 | bot-cg | File Added: 0002-taler-api-allow-a-preflight-the-request-headers-it-n.patch |