auth_request directive equivalent?

#1
Trying to check if the current session has been authorized by accessing an URI. The documentation says it is an auth_request directive, at least in NGNX which returns code 401 if it is unauthorized or 302 if it is:

location / {
auth_request /oauth2/auth;
error_page 401 = @oauth2_signin;
proxy_pass http://backend/;
}

location @oauth2_signin {
return 302 /oauth2/sign_in?rd=$scheme://$host$request_uri;
}


Doc: https://oauth2-proxy.github.io/oauth2-proxy/configuration/integrations/nginx/

Does OLS have an equivalent to this? Any way to achieve the same effect in a different manner?

I also tried to play with %{HTTP:Authorization} in Rewrite but haven't managed to separate the authorized vs. unauthorized sessions and set up rules as result. OLS activates RewriteRule no matter what %{HTTP:Authorization} returns:


RewriteRule .\* - \[E=HTTP_AUTHORIZATION:%{HTTP:Authorization}\]
RewriteCond %{HTTP:Authorization} ^\$


In the browser I occasionally get a header as "authorization: Bearer undefined"

I am trying to redirect the user either to the (3rd party) authorizing service/page if session is NOT yet authorized, respectively to give them access to the app.
Any suggestions ?
 
Top