Skip to content

Commit f9193fa

Browse files
authored
Merge pull request #175 from grafbase/brabier/vxysvopuvpyr
update SDK to 0.22
2 parents ff8a6f0 + bc2fbd0 commit f9193fa

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ base64 = "0.22.1"
6060
bytes = { version = "1.10.1", features = ["serde"] }
6161
chrono = "0.4.40"
6262
clap = "4.5.36"
63-
ctor = "0.4"
63+
ctor = "0.5"
6464
duration-str = "0.17"
6565
enumflags2 = "0.7.11"
6666
field-selection-map = { git = "https://github.com/grafbase/grafbase", package = "engine-field-selection-map" }
@@ -69,7 +69,7 @@ futures-util = "0.3.31"
6969
fxhash = "0.2.1"
7070
grafbase-database-definition = { version = "0.1.0", path = "crates/database-definition" }
7171
grafbase-postgres-introspection = { version = "0.1.0", path = "crates/postgres-introspection" }
72-
grafbase-sdk = "0.21.1"
72+
grafbase-sdk = "0.22.1"
7373
hashbrown = "0.15"
7474
http = "1.3"
7575
indexmap = "2.9.0"

extensions/jwt/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,17 @@ impl AuthenticationExtension for Jwt {
121121

122122
impl Jwt {
123123
fn decoder(&mut self) -> Result<Decoder<'_>, ErrorResponse> {
124+
// If we don't have the JWKS yet or poll interval expired, we try to load the JWKS.
124125
if self
125126
.jwks
126127
.as_ref()
127128
.is_none_or(|(_, ts)| ts.elapsed() > self.config.poll_interval)
128129
{
129130
let ts = Instant::now();
130-
let (jwks, bytes) = self
131+
let (on_cache_miss, bytes) = self
131132
.jwks_cache
132-
.get_or_insert(self.config.url.as_str(), || {
133+
.try_get_or_insert(self.config.url.as_str(), || {
134+
log::debug!("Fetching JWKS from {}", self.config.url);
133135
let request = HttpRequest::get(self.config.url.clone()).build();
134136
let response = http::execute(request)?;
135137
let bytes = response.into_bytes();
@@ -140,7 +142,9 @@ impl Jwt {
140142
log::error!("Failed to retrieve JWKS: {err}");
141143
ErrorResponse::internal_server_error()
142144
})?;
143-
let jwks: Jwks = match jwks {
145+
// Either it's a cache hit and we need to parse the bytes or it's a cache miss and we
146+
// parsed the JWKS already.
147+
let jwks: Jwks = match on_cache_miss {
144148
Some(jwks) => jwks,
145149
_ => serde_json::from_slice(&bytes).map_err(|err| {
146150
log::error!("Failed to parse JWKS: {err}");

0 commit comments

Comments
 (0)