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 overriding state variable #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openid_connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function getAuthZArgs(r) {

authZArgs += "&code_challenge_method=S256&code_challenge=" + pkce_code_challenge + "&state=" + r.variables.pkce_id;
} else {
authZArgs += "&state=0";
authZArgs += "&state=" + r.variables.state;
}
return authZArgs;
}
Expand All @@ -272,4 +272,4 @@ function idpClientAuth(r) {
} else {
return "code=" + r.variables.arg_code + "&client_secret=" + r.variables.oidc_client_secret;
}
}
}
4 changes: 2 additions & 2 deletions openid_connect.server_conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
internal;
proxy_ssl_server_name on; # For SNI to the IdP
proxy_set_header Content-Type "application/x-www-form-urlencoded";
proxy_set_body "grant_type=authorization_code&client_id=$oidc_client&$args&redirect_uri=$redirect_base$redir_location";
proxy_set_body "grant_type=authorization_code&client_id=$oidc_client&state=$state&$args&redirect_uri=$redirect_base$redir_location";
proxy_method POST;
proxy_pass $oidc_token_endpoint;
}
Expand All @@ -51,7 +51,7 @@
internal;
proxy_ssl_server_name on; # For SNI to the IdP
proxy_set_header Content-Type "application/x-www-form-urlencoded";
proxy_set_body "grant_type=refresh_token&refresh_token=$arg_token&client_id=$oidc_client&client_secret=$oidc_client_secret";
proxy_set_body "grant_type=refresh_token&refresh_token=$arg_token&client_id=$oidc_client&state=$state&client_secret=$oidc_client_secret";
proxy_method POST;
proxy_pass $oidc_token_endpoint;
}
Expand Down
5 changes: 5 additions & 0 deletions openid_connect_configuration.conf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ map $host $oidc_hmac_key {
default "ChangeMe";
}

map $host $state {
# Unable to use this state if PKCE is enabled
default 0;
}

map $proto $oidc_cookie_flags {
http "Path=/; SameSite=lax;"; # For HTTP/plaintext testing
https "Path=/; SameSite=lax; HttpOnly; Secure;"; # Production recommendation
Expand Down