-
Notifications
You must be signed in to change notification settings - Fork 16
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
Why disabling auth_jwt_validate_sig in the token verification subrequest? #4
Comments
In the preaccess phase, subrequests are not handled properly, so the verification process is not performed. |
Can you please elaborate, how are they not handled properly? Also, this is something worth mentioning in the readme. Related question, is it possible to somehow run auth_jwt before auth_request? |
Annotated. see: https://github.com/kjdev/nginx-auth-jwt/blob/main/README.md?plain=1#L228
When combined with auth_reqest it looks like this. config: # # auth_jwt_conf
# auth_jwt "" token=$session_jwt;
# error_page 401 = @oidc_error;
# auth_jwt_key_request /_jwks_uri;
# proxy_pass http://my_backend;
#OK: proxy_pass content
location = /auth/ok {
include auth_jwt_conf;
auth_request /auth_request/200;
auth_jwt_validate_alg RS256;
}
# NG: 403 error page
location = /auth/ng {
include auth_jwt_conf;
auth_request /auth_request/403;
auth_jwt_validate_alg RS256;
}
# NG: @oidc_error page
location = /auth/ok/invalid {
include auth_jwt_conf;
auth_request /auth_request/200;
auth_jwt_validate_alg ES256; # invalid auth_jwt
}
# NG: @oidc_error page
location = /auth/ng/invalid {
include auth_jwt_conf;
auth_request /auth_request/403;
auth_jwt_validate_alg ES256; # invalid auth_jwt
}
location = /auth_request/200 {
return 200 "OK";
}
location = /auth_request/403 {
return 403 "Forbidden";
} |
I see now, I didn’t understand what exactly it meant before. Why are nested in-memory subrequest a problem?
The problem is with |
I'm not sure if it's possible without two steps since they are both access faces. upstream auth_request_backend {
zone auth_request_backend 64k;
server 127.0.0.1:8889;
}
server {
listen 8889;
location / {
# valid auth_request
auth_request /test;
proxy_set_header username "$http_username";
proxy_pass http://my_backend;
}
location /test {
if ($http_username ~* "XXX") {
return 200;
}
return 403;
}
}
server {
location /auth/test {
# valid auth_jwt
auth_jwt_validate_alg RS256;
auth_jwt "" token=$session_jwt;
error_page 401 = @oidc_error;
auth_jwt_key_request /_jwks_uri;
proxy_set_header username $jwt_claim_sub;
proxy_pass http://auth_request_backend;
}
}
|
This workaround doesn’t look very good. :/ If It might be helpful if the module also accepts JWKS as a value (JSON encoded as a string), then I could more easily handle it myself from njs. |
Aha, nginx (not this module) forbids nested subrequests, that’s the problem we face here. I found it in nginx/njs#339 (comment). However, inside njs, I can use |
What’s the reason for disabling signature verification in the ID token verification subrequest?
https://github.com/kjdev/nginx-auth-jwt/tree/main/example#changed-setting-for-id-token-verification
The text was updated successfully, but these errors were encountered: