(token: &str)
| 81 | } |
| 82 | |
| 83 | fn install_token_slot(token: &str) -> Result<TokenSlot> { |
| 84 | let bearer = AsciiMetadataValue::try_from(format!("Bearer {token}")) |
| 85 | .into_diagnostic() |
| 86 | .wrap_err("sandbox JWT contained characters not valid for a header value")?; |
| 87 | if let Some(existing) = TOKEN_SLOT.get() { |
| 88 | *existing.write().expect("token slot poisoned") = bearer; |
| 89 | return Ok(existing.clone()); |
| 90 | } |
| 91 | let slot: TokenSlot = Arc::new(RwLock::new(bearer)); |
| 92 | let _ = TOKEN_SLOT.set(slot.clone()); |
| 93 | Ok(TOKEN_SLOT.get().cloned().unwrap_or(slot)) |
| 94 | } |
| 95 | |
| 96 | /// gRPC interceptor that injects `authorization: Bearer <token>` on every |
| 97 | /// outbound request. The token lives in a shared [`TokenSlot`] so the renewal |
no test coverage detected