How to handle Azure AD Authentication with Kuberne

2019-08-21 09:53发布

问题:

I have an ASP.NET Core 2 application running in a pod.

It is nothing fancy. Just the default app created by Visual Studio, with "School/Work account"-authentication enabled.

My ingress points to the service at /

- path: /
  backend:
    serviceName: debug-ui
    servicePort: 80

When i hit that endpoint (/) i am being redirected to Azure AD login. I authenticate and Azure AD redirects to /signin-oidc which is normal for AD login. So far everything works as expected.

The problem is that the ingress responds with a "502 - Bad gateway", probably because the ingress sees /signin-oidc as a route to another (non-existing) service, but it should have been an endpoint on the application at / itself.

The application running at / also have /about and a /contact - which works fine when auth is disabled

The /signin-oidc is called as HTTP POST with the authentication token. (JWT)

How do i get around this issue ?

Technologies :

  • Kubernetes on Azure ACS
  • nginx-ingress-controller
  • Azure Active Directory
  • .NET Core 2

回答1:

  paths:
  - path: /tea
    backend:
      serviceName: tea-svc
      servicePort: 80
  - path: /coffee
    backend:
      serviceName: coffee-svc
      servicePort: 80