How to find the cause of an error
To see how the cluster authenticates a user, run the following command with the kubeconfig file of the user:- If kubectl can’t get a token from the IdP, see Sign-in errors.
- If the output is
error: You must be logged in to the server (Unauthorized), the API server rejected the token. See Unauthorized error. - If the output shows the username and groups of the user, the user is authenticated. If the user still can’t run commands, compare the username and groups with your role-based access control (RBAC) bindings. See Forbidden error.
Configuration rejected by the cluster
The cluster checks the provider configuration before it applies it. The error message names the parameter that failed the check. Common causes:- The cluster runs an unrecommended Kubernetes version.
- A prefix starts with
system:ornebius:. - Two providers have the same name or the same issuer URL.
- The issuer URL doesn’t use HTTPS, contains a query or a fragment, or points to the cluster itself.
- A claim mapping has both
claimandexpression, or an expression mapping has aprefix. - A claim validation rule has both
claimandexpression, an exact-match rule has amessage, or an expression rule has arequired_value. - A Common Expression Language (CEL) expression doesn’t compile.
- An expression uses
claims.emailwithout checkingemail_verified. issuer.certificate_authorityisn’t a valid PEM bundle.- The cluster has more than 64 providers.
Sign-in errors
The user can’t complete the sign-in, so kubectl doesn’t get a token. Check that the user is assigned to the client application in the IdP. If users sign in with kubelogin, also check the following:- kubelogin is installed. If it isn’t, kubectl reports that the
oidc-logincommand is unknown. For instructions, see How to sign in to the cluster. - The client application in the IdP allows the authorization code grant type and the
http://localhost:8000redirect URI. If it doesn’t, the IdP shows an error after the user signs in. - The
--oidc-issuer-urland--oidc-client-idvalues in the kubeconfig file match the issuer URL of the IdP and the client ID of the application.
Unauthorized error
The API server rejected the token. Check the following:- The update operation that added or changed the provider has completed.
- The issuer URL and the discovery document are publicly accessible over HTTPS.
- The
issuerfield of the discovery document matchesissuer.urlexactly, including the trailing slash. To see the document, open<issuer_URL>/.well-known/openid-configurationin a browser. - The public keys of the IdP include the key that signed the token.
- The token hasn’t expired.
- The
audclaim of the token contains one of the values inissuer.audiences. - The token contains the claims that the mappings use, and
email_verifiedisn’tfalse. - The token passes all validation rules.
- The mapped username and groups don’t start with
system:.
Forbidden error
The user is authenticated but has no permission for the request. Get the mapped username and groups of the user and check the following:- Your RBAC bindings use the same names as the output, including the prefixes. For more information, see How to grant access with RBAC.
- If the output has no groups from the IdP, the ID token has no
groupsclaim. Configure the IdP to add the claim. If the IdP adds it only for a separate scope, request this scope in the kubeconfig file. For more information, see How to prepare a kubeconfig file for users.