Skip to content

Commit

Permalink
Fix: Double URL encoding in proxy upstream after internalRedirect
Browse files Browse the repository at this point in the history
  • Loading branch information
route443 committed Apr 20, 2022
1 parent db991ec commit e0caf57
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions openid_connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ var newSession = false; // Used by oidcAuth() and validateIdToken()

export default {auth, codeExchange, validateIdToken, logout};

function retryOriginalRequest(r) {
delete r.headersOut["WWW-Authenticate"]; // Remove evidence of original failed auth_jwt
r.internalRedirect(r.variables.uri + r.variables.is_args + (r.variables.args || ''));
}

function auth(r) {
if (!r.variables.refresh_token || r.variables.refresh_token == "-") {
newSession = true;
Expand Down Expand Up @@ -88,8 +93,7 @@ function auth(r) {
r.variables.refresh_token = tokenset.refresh_token; // Update key-value store
}

delete r.headersOut["WWW-Authenticate"]; // Remove evidence of original failed auth_jwt
r.internalRedirect(r.variables.request_uri); // Continue processing original request
retryOriginalRequest(r); // Continue processing original request
}
);
} catch (e) {
Expand Down

0 comments on commit e0caf57

Please sign in to comment.