Welcome! Log In Create A New Profile

Advanced

Stuck with SSO/auth_request

Posted by designerfh 
Stuck with SSO/auth_request
August 22, 2016 08:37AM
Hi All,
Complete nginx noob. I'm trying to implement SSO similar to this: https://developers.shopware.com/blog/2015/03/02/sso-with-nginx-authrequest-module/ however I am using node/passport/azure-ad for my authentication service.

The issue I am running into is - how do I get the originally requested route /app1 when the subrequest returns a 401? I'd like to pass that along to the passport.js middleware as a parameter so it will redirect me properly after authentication (which involves several redirects).

server {
listen 80;
server_name localhost;

error_page 401 /login;

location /login {
set $app //this is where I get stuck
rewrite ^/login http://localhost:3200/login?appUrl=$app;
}

location /app1 {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
auth_request /auth;
}

location /auth {
proxy_pass http://localhost:3200/auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
}

I've tried returning the value from node as a custom header, tried $upstream_http_, $sent_http_, $http_,
Tried storing it as a session variable, but express sees the subrequest as a different session than navigating directly, etc.

Any help would be appreciated!

Thanks
Jason
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 210
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready