Skip to content

Commit 292f79b

Browse files
authored
Merge pull request #9230 from ZhiHanZ/share-head
feat: add X-DATABEND-TENANT in sharing request
2 parents 7028adb + 6033112 commit 292f79b

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Cargo.lock

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

src/query/sharing/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ backon = "0.2"
1616
base64 = "0.13.0"
1717
bytes = "1"
1818
common-auth = { path = "../../common/auth" }
19+
common-config = { path = "../config" }
20+
1921
http = "0.2"
2022
log = "0.4"
2123
moka = "0.9"

src/query/sharing/src/signer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use anyhow::anyhow;
2222
use anyhow::Result;
2323
use bytes::Bytes;
2424
use common_auth::RefreshableToken;
25+
use common_config::GlobalConfig;
2526
use http::header::AUTHORIZATION;
2627
use http::header::CONTENT_LENGTH;
2728
use http::Method;
@@ -33,6 +34,8 @@ use opendal::raw::HttpClient;
3334
use opendal::raw::Operation;
3435
use opendal::raw::PresignedRequest;
3536

37+
const TENANT_HEADER: &str = "X-DATABEND-TENANT";
38+
3639
/// SharedSigner is used to track presign request, and it's response.
3740
///
3841
/// There is an internal cache about presign request. Getting an expired
@@ -149,11 +152,13 @@ impl SharedSigner {
149152
.collect();
150153
let bs = Bytes::from(serde_json::to_vec(&reqs)?);
151154
let auth = self.token.to_header().await?;
155+
let requester = GlobalConfig::instance().as_ref().query.tenant_id.clone();
152156
let req = Request::builder()
153157
.method(Method::POST)
154158
.uri(&self.endpoint)
155159
.header(AUTHORIZATION, auth)
156160
.header(CONTENT_LENGTH, bs.len())
161+
.header(TENANT_HEADER, requester)
157162
.body(AsyncBody::Bytes(bs))?;
158163
let resp = self.client.send_async(req).await?;
159164
let bs = resp.into_body().bytes().await?;

0 commit comments

Comments
 (0)