K8S Dashboard login with url

5/26/2021

I'm running an eks cluster, installed k8s dashboard etc. All works fine, I can login in the UI in

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login

Is there a way for me to pass the token via the url so I won't need a human to do this? Thanks!

-- J. Doe
amazon-eks
dashboard
kubernetes

1 Answer

5/26/2021

Based on official documentation it is impossible to put your authentication token in URL.

As of release 1.7 Dashboard supports user authentication based on:

As you can see, only the first option bypasses the Dashboard login view. So, what is Bearer Authentication?

Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name “Bearer authentication” can be understood as “give access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request. The client must send this token in the Authorization header when making requests to protected resources:

You can find more information about Baerer Authentication here.

The question now is how you can include the authentication header in your request. There are many ways to achieve this:

  • curl command - example:
curl -H "Authorization: Bearer <TOKEN_VALUE>" <https://address-your-dashboard>
  • Postman application - here is good answer to set up authorization header with screenshots.
  • reverse proxy - you can be achieve this i.e. by configuring reverse proxy in front of Dashboard. Proxy will be responsible for authentication with identity provider and will pass generated token in request header to Dashboard. Note that Kubernetes API server needs to be configured properly to accept these tokens. You can read more about it here. You should know, that this method is potentially insecure due to Man In The Middle Attack when you are using http.

You can also read very good answers to the question how to sign in kubernetes dashboard.

-- Mikołaj Głodziak
Source: StackOverflow