Skip to main content

fetch_public_config

Function fetch_public_config 

Source
pub async fn fetch_public_config(
    client: &Client,
    server_url: &str,
) -> Result<PublicConfig, OidcError>
Expand description

Ask the Visdom server which realm to authenticate against.

“Is this instance configured for SSO, and against which realm?”

Two outcomes must stay distinguishable, because the advice differs and one is permanent while the other is not:

  • 200 {"oidc_enabled": false} → the instance has no Keycloak at all. PERMANENT; the user needs a tvk_ API key (OidcError::NoKeycloak).
  • any 5xx → the server (or an intermediary/web proxy in front of it) is unhealthy right now. RETRYABLE (OidcError::IdpUnavailable), and deliberately never phrased as “go get an API key”: telling a user in the middle of a 30-second restart to change credentials is unactionable.

The not-configured answer is a 200 rather than a 503 because a 503 from a healthy server makes load balancers fail the pod out and 5xx SLO alerts fire. The 5xx branch remains regardless, since an intermediary can still produce one when the backend is down.

oidc_enabled: true with issuer or cli_client_id missing is a hard error rather than an empty-string default: the alternative is a device authorization POSTed to "/.well-known/...", failing with something unrelated to the actual misconfiguration.