webauthn_proxy icon indicating copy to clipboard operation
webauthn_proxy copied to clipboard

Diagnosing cookie issues with nginx

Open AlanIWBFT opened this issue 9 months ago • 1 comments

So, there are a few caveats with auth_request. webauthn_proxy wants to manipulate cookies (mainly expiration) in HandleAuth, which isn't going to be respected until you add the following to your location:

auth_request_set $new_cookie $sent_http_set_cookie;
add_header Set-Cookie $new_cookie;

Then, the next issue is error_page 401 = /webauthn/login?redirect_url=$uri;. This form causes nginx to do an internal redirect, i.e. replacing the content at $uri with the login page, overriding the headers including cookies HandleAuth wants to clear and results in redirect indefinitely. Further, if there is any space in $uri, it causes the Go http server (not nginx) to throw a 400 bad request response. These can be fixed by:

error_page 401 = $scheme://$http_host/webauthn/login?redirect_url=$uri;

which forces nginx to do an external redirect and HandleLogin will actually see redirect_url (yes, it was not doing anything) I caught these issues by setting hardTimeout < softTimeout. Yes, I know it is an invalid case, yet I believe making ExpireWebauthnSession work in HandleAuth does have some value.

AlanIWBFT avatar Mar 19 '25 09:03 AlanIWBFT

Your fix for the 401 issue worked fot me, thank you @AlanIWBFT !

nginx version: nginx/1.24.0 (Ubuntu) using docker version with latest image quiq/webauthn_proxy:latest created 2025-06-11 13:46:09

MartinVincent avatar Jun 20 '25 20:06 MartinVincent