Kang Tao
Kang Tao

Reputation: 31

How to pass headers to auth-url in nginx ingress

What is the correct way to pass auth header in auth-url for external auth? Below is my current nginx ingress config:

nginx.ingress.kubernetes.io/auth-cache-key: $remote_user$http_authorization
nginx.ingress.kubernetes.io/auth-response-headers: Authorization
nginx.ingress.kubernetes.io/auth-signin: mydomain/signin
nginx.ingress.kubernetes.io/auth-url: mydomain/check

Traffic will first go to /signin, and after my external oauth signin, it will go to my another /redirect endpoint where I send Authorization header, and redirect back to the original url. But next time when traffic goes to original url and hits /check, it does not pass Authorization header to my /check endpoint so it fails the auth verification again. I thought nginx.ingress.kubernetes.io/auth-response-headers would pass the header for me but it did not work. Do you know how to pass header in my case?

Many thanks!

Upvotes: 3

Views: 8175

Answers (1)

browser-bug
browser-bug

Reputation: 2051

Have you tried setting specifically the header inside the auth-snippet annotation?

nginx.ingress.kubernetes.io/auth-snippet: |
    proxy_set_header Authorization $http_authorization;

Upvotes: 3

Related Questions