You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auth: answer 401 with a sanitized message when /auth/refresh rejects an expired or rotated refresh credential #31346
When the stored refresh credential is expired or has been rotated away, POST/GET /api/v1/auth/refresh answers HTTP 500 on the Basic, LDAP and confidential-OIDC paths (catch (Exception e) → SC_INTERNAL_SERVER_ERROR). The SAML path already answers 401 for the expiry case.
Two problems with the 500:
Wrong semantics — the server is rejecting the caller's credentials, which is a 401. Any API client (SDKs, scripts, reverse proxies with retry-on-5xx policies) reads the 500 as a transient server fault and retries a request that can never succeed. Server-side, a routine credential expiry lands in error logs/alerting as if the service were failing.
Token leak — the 500 body echoes e.getMessage(), which embeds the refresh token UUID ("Expired token. Please login again : <uuid>").
After #31103, the UI signs out on any failed refresh, so the browser UX is not affected — this is about correct HTTP semantics for the endpoint itself and keeping credentials out of response bodies.
Expected behavior
Expired refresh token (CustomExceptionMessage, 400), rotated-away/unknown token (EntityNotFoundException, 404), empty token (BadRequestException) → 401 with a fixed, sanitized message.
Genuine server faults (JWT signing failure, DB unavailable) → 500, unchanged — a backend outage must never read as "your session is invalid".
Full exception detail (including the UUID) stays in server logs.
Verified reproduction
On a live stack: log in (basic auth), UPDATE user_tokens SET json = JSON_SET(json,'$.expiryDate',1000), call /api/v1/auth/refresh with the session cookie → 500 with the token UUID in the body. With a stopped DB the same call also answers 500 — the two cases are indistinguishable to clients today.
Activity
Fixes open-metadata#31346: answer 401 without echoing the token when …