# Not able to authenticate Dashboard with oauth and Google

**URL:** <https://discuss.kubernetes.io/t/not-able-to-authenticate-dashboard-with-oauth-and-google/30525>\
**Category:** General Discussions\
**Tags:** security, network\
**Created:** [November 16, 2024, 1:26pm UTC](https://discuss.kubernetes.io/t/not-able-to-authenticate-dashboard-with-oauth-and-google/30525 "2024-11-16T13:26:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcfdez](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/mcfdez/32/16267_2.png) [@mcfdez](https://discuss.kubernetes.io/u/mcfdez)\
**Post date:** [November 16, 2024, 1:26pm UTC](https://discuss.kubernetes.io/t/not-able-to-authenticate-dashboard-with-oauth-and-google/30525/1 "2024-11-16T13:26:37Z")

</div>

Hello,

I have configured the **oauth-proxy** component with the **Google provider** to protect certain applications in my cluster and that they are only accessible if we use this authentication system, among them, the **Kubernetes Dashboard**.

With oauth-proxy configured, I have created a manifest to create an **Ingress** resource where the authentication path is declared which is also protected with SSL through **Cert Manager**.

Also, I created the Ingress resource to expose the Dashboard application under an SSL protected domain.

When I access that Dashboard domain, the Google authentication flow starts, and everything seems to work fine until I am redirected back to the Dashboard after authenticating. At that point, I get the Dashboard login where it asks me to add an access token.

So, I suspect that somewhere along the way I am leaving some settings out, as Dashboard is not able to recognize that I have authenticated.

I need help, thanks!

**Configuration details**

When I install oauth-proxy, I install it via helm:

```auto
helm repo add oauth2-proxy https://oauth2-proxy.github.io/manifests
helm install oauth2-proxy oauth2-proxy/oauth2-proxy \
  --namespace infrastructure \
  --values ./k8s/infrastructure/oauth2-proxy/installation.yml

```

With these values in the **installation.yml** :

```auto
config:
  clientID: "<GOOGLE_CLIENT_ID>"
  clientSecret: "<GOOGLE_CLIENT_SECRET>"
  provider: "google"
  redirectURL: "<REDIRECT_URL>"
  cookieSecret: "<COOKIE_SECRET>"
extraArgs:
  - --whitelist-domain=app1.example.com
  - --whitelist-domain=dashboard.example.com
  - --whitelist-domain=authentication.example.com
  - --cookie-domain=.example.com
  - --set-authorization-header
  - --pass-authorization-header
  - --pass-user-headers
  - --pass-access-token
  - --set-xauthrequest
service:
  portNumber: 4180

```

This is the **ingress resource** I apply to expose the authentication urls:

```auto
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: oauth2-proxy-ingress
  namespace: infrastructure
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    cert-manager.io/issuer: "letsencrypt-issuer"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - authentication.example.com
      secretName: oauth2-proxy-tls-certificate
  rules:
    - host: authentication.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: oauth2-proxy
                port:
                  number: 4180

```

Finally, this is the **ingress resource** that exposes the Dashboard application:

```auto
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: administration
  annotations:
    cert-manager.io/issuer: "letsencrypt-issuer"
    nginx.ingress.kubernetes.io/rewrite-target: /
    #nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    nginx.ingress.kubernetes.io/auth-url: "https://authentication.example.com/oauth2/auth"
    nginx.ingress.kubernetes.io/auth-signin: "https://authentication.example.com/oauth2/start?rd=$scheme://$host$request_uri"
    nginx.ingress.kubernetes.io/auth-response-headers: "x-auth-request-user,x-auth-request-email,authorization"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - dashboard.example.com
      secretName: dashboard-tls-certificate
  rules:
    - host: dashboard.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: kubernetes-dashboard-kong-proxy
                port:
                  number: 443

```

---

<div class="post-metadata">

**Author:** ![jamallmahmoudi](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jamallmahmoudi/32/5803_2.png) [@jamallmahmoudi](https://discuss.kubernetes.io/u/jamallmahmoudi)\
**Post date:** [November 17, 2024, 3:10pm UTC](https://discuss.kubernetes.io/t/not-able-to-authenticate-dashboard-with-oauth-and-google/30525/2 "2024-11-17T15:10:54Z")

</div>

Hi mcfdez,

I ran this scenario in production a few years ago using the setup from this link, and it worked well.  
Take a look at it – you might find the answer to your question there.

`https://geek-cookbook.funkypenguin.co.nz/recipes/kubernetes/oauth2-proxy/`

---

<div class="post-metadata">

**Author:** ![mcfdez](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/mcfdez/32/16267_2.png) [@mcfdez](https://discuss.kubernetes.io/u/mcfdez)\
**Post date:** [November 17, 2024, 6:57pm UTC](https://discuss.kubernetes.io/t/not-able-to-authenticate-dashboard-with-oauth-and-google/30525/3 "2024-11-17T18:57:15Z")

</div>

Hi @jamallmahmoudi

Thank you for your input. Aperently I have everything configured correctly, but it’s as if the authentication token that Google sends me after authenticating, gets lost on the way between oauth-\>ingress-\>dashboard. Another option could be that in Dashboard I had to configure something additional, but I find it suspicious that when I am returned to my Dashboard public url by the proxy, from the DevTools I don’t see any header. That makes me suspicious.

---

<div class="post-metadata">

**Author:** ![Gagan\_B\_R](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/gagan_b_r/32/17292_2.png) [@Gagan\_B\_R](https://discuss.kubernetes.io/u/Gagan_B_R)\
**Post date:** [May 15, 2025, 12:07pm UTC](https://discuss.kubernetes.io/t/not-able-to-authenticate-dashboard-with-oauth-and-google/30525/4 "2025-05-15T12:07:54Z")

</div>

I am stuck in the same problem, were you able to find anything about this
