Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scope of nginx auth_request_set #555

Open
andriykrefer opened this issue Mar 7, 2024 · 1 comment
Open

scope of nginx auth_request_set #555

andriykrefer opened this issue Mar 7, 2024 · 1 comment

Comments

@andriykrefer
Copy link

andriykrefer commented Mar 7, 2024

Hi,

This is a question about the nginx example config.

Not sure if it any conflicting configuration on my side (very possible).

Config from example:

    # send all requests to the `/validate` endpoint for authorization
    auth_request /validate;

    location = /validate {
      ...

      # these return values are used by the @error401 call
      auth_request_set $auth_resp_jwt $upstream_http_x_vouch_jwt;
      auth_request_set $auth_resp_err $upstream_http_x_vouch_err;
      auth_request_set $auth_resp_failcount $upstream_http_x_vouch_failcount;
    }

    # if validate returns `401 not authorized` then forward the request to the error401block
    error_page 401 = @error401;

    location @error401 {
        # redirect to Vouch Proxy for login
        # ************ $auth_resp_jwt and others are empty **************
        return 302 https://vouch.yourdomain.com:9090/login?url=$scheme://$http_host$request_uri&vouch-failcount=$auth_resp_failcount&X-Vouch-Token=$auth_resp_jwt&error=$auth_resp_err;
    }

But the variables created with "auth_request_set" directive are not available at the redirected page.
I was only able to get its values, changing its scopes, like:

    auth_request /validate;
    # ****** PUT HERE **************
    auth_request_set $auth_resp_jwt $upstream_http_x_vouch_jwt;
    auth_request_set $auth_resp_err $upstream_http_x_vouch_err;
    auth_request_set $auth_resp_failcount $upstream_http_x_vouch_failcount;

    location = /validate {
      ...    
    }

Any clue why did this happen?

I´m also not sure if my change may cause other problems

@bnfinet
Copy link
Member

bnfinet commented Mar 23, 2024

I'm not sure I'm following this correctly.

Could you please clarify the scope of the variables with a more complete example, possibly in a gist?

Which nginx version are you running?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants