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

Support a /validate for use with ngx_http_auth_request_module #120

Open
pecigonzalo opened this issue Feb 4, 2019 · 2 comments
Open

Support a /validate for use with ngx_http_auth_request_module #120

pecigonzalo opened this issue Feb 4, 2019 · 2 comments

Comments

@pecigonzalo
Copy link

It would be great to have a /something endpoint that could be used with NGINX https://nginx.org/en/docs/http/ngx_http_auth_request_module.html.

If you can give me some pointers, im happy to do the PR

@smancke
Copy link
Member

smancke commented Feb 4, 2019

Hi @pecigonzalo, yes would make perfect sense.
You should make the resource at /login/validate and it should return the token content as JSON, if the Accept-Header for JSON is present. The implementation should share the code with https://github.com/tarent/loginsrv/blob/14651bba903922fccb34776ef16aaf632c2fd878/login/handler.go#L151-L160

Please do not forget the tests and documentation in the README :)

@pecigonzalo
Copy link
Author

pecigonzalo commented Feb 4, 2019

@smancke I was going through the code, and we might not even need the path.
EG: NGINX

server {
    listen 80;


    location /authz/ {
        internal;
        proxy_pass http://auth:8080/;

        proxy_set_header Accept "application/json";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme  $scheme;

    }

    location /login {
        proxy_pass http://auth:8080;

        proxy_set_header X-Real-IP               $remote_addr;
        proxy_set_header X-Scheme                $scheme;
        proxy_set_header X-Auth-Request-Redirect $request_uri;
    }

    location / {
        auth_request /authz/login;
        error_page 401 = /login;
        error_page 403 = /login;

        root   /usr/share/nginx/html;
    }
}

Seems to work for the most part, except for the fact that

  • I believe /login should return 401 not 403
  • Im setting /login json as a separate locaiton, to avoid the client then doing POST /login and getting JWT return.
  • We might make it cleaner by just doing an @this location, but then we can put the path, or we have to use a rewrite.

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

No branches or pull requests

2 participants