bitly / oauth2_proxy

A reverse proxy that provides authentication with Google, Github or other provider
MIT License
5.1k stars 1.21k forks source link

Refresh tokens never gets sent to client using auth_request #605

Open jeisen opened 6 years ago

jeisen commented 6 years ago

I'm having an issue using refresh tokens on nginx using auth_requests. After the refresh interval has passed, oauth2_proxy continues to allow traffic to the underlying resource, and says it is providing a new token. However, that token never gets sent to the client.

Here is my nginx config: ` location ~ ^/oauth2/.* { proxy_pass http://localhost:4180; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Auth-Request-Redirect $request_uri;

location = /oauth2/auth {
  proxy_pass       http://localhost:4180;
  proxy_set_header Host             $host;
  proxy_set_header X-Real-IP        $remote_addr;
  proxy_set_header X-Scheme         $scheme;
  proxy_set_header Content-Length   "";
  proxy_pass_request_body           off;
}

location ~ ^.* {
  satisfy any;

  allow 127.0.0.1;

  auth_request /oauth2/auth;
  error_page 401 = /oauth2/sign_in;

  # pass information via X-User and X-Email headers to backend,
  # requires running with --set-xauthrequest flag
  auth_request_set $user   $upstream_http_x_auth_request_user;
  auth_request_set $email  $upstream_http_x_auth_request_email;
  proxy_set_header X-User  $user;
  proxy_set_header X-Email $email;

  # if you enabled --cookie-refresh, this is needed for it to work with auth_request
  auth_request_set $auth_cookie $upstream_http_set_cookie;
  add_header Set-Cookie $auth_cookie;

  try_files $uri $uri.html  /myapp_maintenance.html @myapp;

}

location @myapp {
    error_page 502 = @myapp_backup;
    proxy_pass http://myapp;
}                                                                                                                                             |

upstream myapp {
    server 127.0.0.1:8411;
}

`

Is there something else I might be missing?