Search code examples
kubernetesazure-active-directorykubectlazure-akskubernetes-dashboard

MSG_LOGIN_UNAUTHORIZED_ERROR while kubernetes dashboard


I deployed kubernetes dashboard in Azure Kubernetes cluster with the help of following command

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml

Applied clusterrole and clusterrolebinding to same cluster on my azure AD object.

ClusterRole.yml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: admin-user-testing
rules:
  - apiGroups:
      ["*"]
    resources: ["*"]
    verbs: ["*"]

ClusterRoleBinding.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user-testing
subjects:
- kind: User
  name: <azure user object id>
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  name: admin-user-testing
  apiGroup: rbac.authorization.k8s.io

For logging into dashboard I am generating the token with the following command

kubelogin get-token --login azurecli --server-id xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx

In output it gives token property

{"kind":"ExecCredential","apiVersion":"client.authentication.k8s.io/v1beta1","spec":{"interactive":false},"status":{"expirationTimestamp":"2023-05-25T15:00:16Z","token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ii1LSTNROW5OUjdiUm9meG1lWmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcWJIWkdldyJ9.eyJhdWQiOiI2ZGFlNDJmOC00MzY4LTQ2NzgtOTRmZi0zOTYwZTI4ZTM2MzAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9jODk1Y2E0ZS02NTg0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxLCJuYmYiOjE2ODUwMjI2ODYsImV4cCI6MTY4NTAyNjgxNiwiYWNyIjoiMSIsImFpbyI6IkFaUUFhLzhUQUFBQW1OL09tTjU5dzhWOU9RczMwOU94dTJBQzNsaGw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xxxxxxxxxxxxxxxxxxxxxxxxx"}}

After executing kubectl proxy and login to token Sign In button is not responding

In networking tab it shows the following error

{
 "status": 401,
 "plugins": [],
 "errors": [
  {
   "ErrStatus": {
    "metadata": {},
    "status": "Failure",
    "message": "MSG_LOGIN_UNAUTHORIZED_ERROR",
    "reason": "Unauthorized",
    "code": 401
   }
  }
 ]
}

Screenshot enter image description here

I have tried multiple solutions but none of them have worked. Please help me resolve this error? Thank you in advance.


Solution

  • The token is probably simply too big to be handled as an auth header. Request headers have a max size of 4096 KB (depends on the browser and/or proxy implementation) - link

    Allow logging in when a very long token is provided (i.e. Azure with groups, etc.) - link to GitHub Repo of Kubernetes dashboard with Feature request where you can see this