Kibana UI displays generic error when API key expires or least‑privilege role blocks access
0 reputation · 28 Mar 2025, 12:23 UTC
0 reputation · 28 Mar 2025, 12:23 UTC
When an API key used by Kibana expires, the UI returns a 401 Unauthorized response and shows an error banner, but does not attempt to obtain a new key or prompt the user to re‑authenticate without a full page reload.
Similarly, if a user’s least‑privilege role does not grant access to a requested Kibana feature, the interface displays a generic access‑denied message rather than indicating which privilege is missing.
Goal: determine why Kibana does not provide automatic token refresh or more specific privilege‑feedback in these situations, given its reliance on the underlying Elasticsearch security realm and configured token TTL.
What mechanisms would be required for Kibana to silently renew an expired API key?
How could the UI be extended to surface role‑based privilege details when access is denied?
Does the behavior change when using OIDC or SAML SSO where the identity provider handles token renewal?
35275 reputation · 28 Mar 2025, 23:56 UTC
Kibana cannot silently renew an expired API key because an API key is a terminal credential; it carries no refresh token and Kibana does not hold the owner's primary password needed to mint a new one. The generic banner appears because Kibana relays coarse 401 (Unauthorized) and 403 (Forbidden) responses from the Elasticsearch security realm. Although they look identical in the browser, they represent distinct failures: one of identity (expiry) and one of permission (privilege).
Confirmed: Elasticsearch returns HTTP 401 for expired or invalidated API keys and HTTP 403 for valid credentials that lack a required privilege. Kibana surfaces both as generic banners, but the Kibana server log records the underlying security_exception and the real status code.
Likely: If a previously working dashboard suddenly fails, the API key has probably expired or been invalidated. If the error appears from the first login for a new user, a missing role privilege is the more consistent explanation.
To renew an expired key without user interaction, Kibana would need a mechanism beyond the key itself:
Note that API keys only expire if created with an explicit expiration. Keys created without one persist until manually invalidated or until the owning user's credentials change.
The message is generic partly to avoid leaking information (revealing which indices or features exist) to unauthorized users. To give actionable feedback, the UI would need to:
_has_privileges API for the current user and resource.With OIDC or SAML, token renewal shifts to the Identity Provider. When the IdP session expires, Kibana typically redirects to the IdP login page instead of showing a generic API error, so the 401 path improves. However, authorization (403) decisions still come from Elasticsearch role mappings, so the generic access-denied behavior for missing privileges persists regardless of the SSO provider.
Reproduce the error, then check the Kibana server log for the Elasticsearch response status (401 vs 403). You can also query Elasticsearch directly:
# Confirm whether the key is still valid and when it expires
GET /_security/api_key
# Check whether the user has the required privileges
GET /_security/user/_has_privileges
{
"index": [{ "names": ["your-index-*"], "privileges": ["read"] }],
"application": [{
"application": "kibana-.kibana",
"privileges": ["feature_discover.read"],
"resources": ["*"]
}]
}After fixing the key or role, reload Kibana in an incognito window so a cached session does not mask the result. Exact UI wording and status codes vary by Elastic Stack version, so trust the logs over the browser banner.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 28 Mar 2025, 19:52 UTC
Elasticsearch returns 401 for an expired API key. Kibana receives that status but has no way to create a new key because the key itself is a terminal credential and the server lacks the user’s primary password.
A 403 response contains a privileges array that lists the required rights. A small UI component can parse that array and show the user which privilege is missing instead of a generic banner.
When Kibana is backed by an IdP that issues refresh tokens, the IdP can supply a new access token on each request, effectively keeping the session alive without Kibana having to manage API keys.