MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / into_response

Method into_response

crates/client-api/src/auth.rs:437–456  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

435
436impl IntoResponse for AuthorizationRejection {
437 fn into_response(self) -> axum::response::Response {
438 // Most likely, the server key was rotated.
439 const ROTATED: (StatusCode, &str) = (
440 StatusCode::UNAUTHORIZED,
441 "Authorization failed: token not signed by this instance",
442 );
443 // The JWT is malformed, see SpacetimeCreds for specifics on the format.
444 const INVALID: (StatusCode, &str) = (StatusCode::BAD_REQUEST, "Authorization is invalid: malformed token");
445 // Sensible fallback if no auth header is present.
446 const REQUIRED: (StatusCode, &str) = (StatusCode::UNAUTHORIZED, "Authorization required");
447
448 log::trace!("Authorization rejection: {self:?}");
449
450 match self {
451 AuthorizationRejection::Jwt(e) if *e.kind() == JwtErrorKind::InvalidSignature => ROTATED.into_response(),
452 AuthorizationRejection::Jwt(_) | AuthorizationRejection::Header(_) => INVALID.into_response(),
453 AuthorizationRejection::Custom(msg) => (StatusCode::UNAUTHORIZED, msg.to_string()).into_response(),
454 AuthorizationRejection::Required => REQUIRED.into_response(),
455 }
456 }
457}
458
459impl SpacetimeAuthHeader {

Calls 2

kindMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected