@@ -48,7 +48,7 @@ function auth(r, afterSyncCheck) {
48
48
return ;
49
49
}
50
50
// Redirect the client to the IdP login page with the cookies we need for state
51
- r . return ( 302 , r . variables . oidc_authz_endpoint + getAuthZArgs ( r ) ) ;
51
+ r . return ( 302 , r . variables . oidc_authz_endpoint + getQueryParamsAuthZ ( r ) ) ;
52
52
return ;
53
53
}
54
54
@@ -260,18 +260,19 @@ function logout(r) {
260
260
r . return ( 302 , r . variables . oidc_logout_redirect ) ;
261
261
}
262
262
263
- function getAuthZArgs ( r ) {
263
+ function getQueryParamsAuthZ ( r ) {
264
264
// Choose a nonce for this flow for the client, and hash it for the IdP
265
265
var noncePlain = r . variables . request_id ;
266
266
var c = require ( 'crypto' ) ;
267
267
var h = c . createHmac ( 'sha256' , r . variables . oidc_hmac_key ) . update ( noncePlain ) ;
268
268
var nonceHash = h . digest ( 'base64url' ) ;
269
- var authZArgs = "?response_type=code&scope=" + r . variables . oidc_scopes + "&client_id=" + r . variables . oidc_client + "&redirect_uri=" + r . variables . redirect_base + r . variables . redir_location + "&nonce=" + nonceHash ;
269
+ var queryParams = "?response_type=code&scope=" + r . variables . oidc_scopes + "&client_id=" + r . variables . oidc_client + "&redirect_uri=" + r . variables . redirect_base + r . variables . redir_location + "&nonce=" + nonceHash ;
270
270
271
- if ( r . variables . oidc_authz_extra_args ) {
272
- authZArgs += "&" + r . variables . oidc_authz_extra_args ;
271
+ if ( r . variables . oidc_authz_extra_query_params ) {
272
+ queryParams += "&" + r . variables . oidc_authz_extra_query_params ;
273
273
}
274
274
275
+ r . variables . nonce_hash = nonceHash ;
275
276
r . headersOut [ 'Set-Cookie' ] = [
276
277
"auth_redir=" + r . variables . request_uri + "; " + r . variables . oidc_cookie_flags ,
277
278
"auth_nonce=" + noncePlain + "; " + r . variables . oidc_cookie_flags
@@ -282,12 +283,13 @@ function getAuthZArgs(r) {
282
283
r . variables . pkce_id = c . createHash ( 'sha256' ) . update ( String ( Math . random ( ) ) ) . digest ( 'base64url' ) ;
283
284
var pkce_code_challenge = c . createHash ( 'sha256' ) . update ( pkce_code_verifier ) . digest ( 'base64url' ) ;
284
285
r . variables . pkce_code_verifier = pkce_code_verifier ;
286
+ r . variables . pkce_code_challenge = pkce_code_challenge ;
285
287
286
- authZArgs += "&code_challenge_method=S256&code_challenge=" + pkce_code_challenge + "&state=" + r . variables . pkce_id ;
288
+ queryParams += "&code_challenge_method=S256&code_challenge=" + pkce_code_challenge + "&state=" + r . variables . pkce_id ;
287
289
} else {
288
- authZArgs += "&state=0" ;
290
+ queryParams += "&state=0" ;
289
291
}
290
- return authZArgs ;
292
+ return queryParams ;
291
293
}
292
294
293
295
function idpClientAuth ( r ) {
0 commit comments