MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / parse_www_authenticate

Function parse_www_authenticate

vmm/src/app/registry.rs:335–352  ·  view source on GitHub ↗

Extract realm and service from a WWW-Authenticate: Bearer header.

(header: &str)

Source from the content-addressed store, hash-verified

333
334/// Extract realm and service from a WWW-Authenticate: Bearer header.
335fn parse_www_authenticate(header: &str) -> (String, String) {
336 let mut realm = String::new();
337 let mut service = String::new();
338
339 for part in header.split(',') {
340 let part = part.trim();
341 if let Some(v) = part
342 .strip_prefix("Bearer realm=\"")
343 .or_else(|| part.strip_prefix("realm=\""))
344 {
345 realm = v.trim_end_matches('"').to_string();
346 } else if let Some(v) = part.strip_prefix("service=\"") {
347 service = v.trim_end_matches('"').to_string();
348 }
349 }
350
351 (realm, service)
352}
353
354// ─── Helpers ────────────────────────────────────────────────────────────────
355

Callers 2

try_fetch_tokenFunction · 0.85

Calls

no outgoing calls

Tested by 1