@@ -118,29 +118,16 @@ test_auth () {
118118 " ${proxy_scheme} ://localhost:${proxy_port} " \
119119 " ${curl_args[@]} "
120120
121- run_log " Check whether PKCE is supported (${name} )"
122- SUPPORT_PKCE=" false" # Whether PKCE is supported in this version of Envoy
123- LOCATION=$( _curl " ${curl_args[@]} " --head " ${proxy_scheme} ://localhost:${proxy_port} /login" | grep location)
124- if [[ " $LOCATION " == * " code_challenge" * ]]; then
125- SUPPORT_PKCE=" true"
126- fi
127-
128121 run_log " Inititiate login (${name} )"
129122 responds_with_header \
130- " HTTP/1.1 302 Found" \
123+ " HTTP/1.1 302 Found" \
124+ " ${proxy_scheme} ://localhost:${proxy_port} /login" \
125+ " ${curl_args[@]} "
126+ responds_with_header \
127+ " location: http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=[A-Za-z0-9_-]\{1,\}&code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
131128 " ${proxy_scheme} ://localhost:${proxy_port} /login" \
132129 " ${curl_args[@]} "
133- if [[ " $SUPPORT_PKCE " == " true" ]]; then
134- responds_with_header \
135- " location: http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=[A-Za-z0-9_-]\{1,\}&code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
136- " ${proxy_scheme} ://localhost:${proxy_port} /login" \
137- " ${curl_args[@]} "
138- else
139- responds_with_header \
140- " location: http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
141- " ${proxy_scheme} ://localhost:${proxy_port} /login" \
142- " ${curl_args[@]} "
143- fi
130+
144131 responds_with_header \
145132 " set-cookie: OauthNonce=" \
146133 " ${proxy_scheme} ://localhost:${proxy_port} /login" \
@@ -153,34 +140,18 @@ test_auth () {
153140 code_verifier=" Fc1bBwAAAAAVzVsHAAAAABjf6i_Hvf8T2dEuEhPhhDNMlp16az-0dxisL-TzJKaZjOMF8nov_pG377FHmpKcsA"
154141 code_challenge=" YRQaBq_UpkWzfr6JvtNnh7LMfmPVcIKVYdV98ugwmLY"
155142 run_log " Fetch the myhub authorization page (${name} )"
156- if [[ " $SUPPORT_PKCE " == " true" ]]; then
157- responds_with_header \
158- " HTTP/1.1 302 Found" \
159- " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=${code_challenge} &code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " \
160- " ${curl_args[@]} "
161- responds_with_header \
162- " Location: ${proxy_scheme} ://localhost:${proxy_port} /authorize?code=" \
163- " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=${code_challenge} &code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " \
164- " ${curl_args[@]} "
165- else
166- responds_with_header \
167- " HTTP/1.1 302 Found" \
168- " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " \
169- " ${curl_args[@]} "
170- responds_with_header \
171- " Location: ${proxy_scheme} ://localhost:${proxy_port} /authorize?code=" \
172- " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " \
173- " ${curl_args[@]} "
174- fi
143+ responds_with_header \
144+ " HTTP/1.1 302 Found" \
145+ " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=${code_challenge} &code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " \
146+ " ${curl_args[@]} "
147+ responds_with_header \
148+ " Location: ${proxy_scheme} ://localhost:${proxy_port} /authorize?code=" \
149+ " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=${code_challenge} &code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " \
150+ " ${curl_args[@]} "
175151
176152 run_log " Return to the app and receive creds (${name} )"
177- if [[ " $SUPPORT_PKCE " == " true" ]]; then
178- CODE=$( _curl " ${curl_args[@]} " --head " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=${code_challenge} &code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " | grep Location | cut -d= -f2 | cut -d\& -f1)
179- RESPONSE=$( _curl " ${curl_args[@]} " --cookie " OauthNonce=${csrf_token} " --cookie " CodeVerifier=${code_verifier} " --head " ${proxy_scheme} ://localhost:${proxy_port} /authorize?code=$CODE &state=${encoded_state} " )
180- else
181- CODE=$( _curl " ${curl_args[@]} " --head " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " | grep Location | cut -d= -f2 | cut -d\& -f1)
182- RESPONSE=$( _curl " ${curl_args[@]} " --cookie " OauthNonce=${csrf_token} " --head " ${proxy_scheme} ://localhost:${proxy_port} /authorize?code=$CODE &state=${encoded_state} " )
183- fi
153+ CODE=$( _curl " ${curl_args[@]} " --head " http://localhost:${PORT_MYHUB} /authorize?client_id=0123456789&code_challenge=${code_challenge} &code_challenge_method=S256&redirect_uri=${proxy_scheme} %3A%2F%2Flocalhost%3A${proxy_port} %2Fauthorize&response_type=code&scope=user%3Aemail&state=${encoded_state} " | grep Location | cut -d= -f2 | cut -d\& -f1)
154+ RESPONSE=$( _curl " ${curl_args[@]} " --cookie " OauthNonce=${csrf_token} " --cookie " CodeVerifier=${code_verifier} " --head " ${proxy_scheme} ://localhost:${proxy_port} /authorize?code=$CODE &state=${encoded_state} " )
184155 echo " $RESPONSE " | grep " HTTP/1.1 302 Found"
185156 echo " $RESPONSE " | grep " location: ${proxy_scheme} ://localhost:${proxy_port} /login"
186157 echo " $RESPONSE " | grep " set-cookie: OauthHMAC="
@@ -329,15 +300,10 @@ run_log "Inititiate dev login (Github)"
329300responds_with_header \
330301 " HTTP/1.1 302 Found" \
331302 " http://localhost:${PORT_DEV_PROXY} /login"
332- if [[ " $SUPPORT_PKCE " == " true" ]]; then
333- responds_with_header \
334- " location: https://github.com/login/oauth/authorize?client_id=XXX&code_challenge=[A-Za-z0-9_-]\{1,\}&code_challenge_method=S256&redirect_uri=http%3A%2F%2Flocalhost%3A${PORT_DEV_PROXY} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
335- " http://localhost:${PORT_DEV_PROXY} /login"
336- else
337- responds_with_header \
338- " location: https://github.com/login/oauth/authorize?client_id=XXX&redirect_uri=http%3A%2F%2Flocalhost%3A${PORT_DEV_PROXY} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
339- " http://localhost:${PORT_DEV_PROXY} /login"
340- fi
303+ responds_with_header \
304+ " location: https://github.com/login/oauth/authorize?client_id=XXX&code_challenge=[A-Za-z0-9_-]\{1,\}&code_challenge_method=S256&redirect_uri=http%3A%2F%2Flocalhost%3A${PORT_DEV_PROXY} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
305+ " http://localhost:${PORT_DEV_PROXY} /login"
306+
341307responds_with_header \
342308 " set-cookie: OauthNonce=" \
343309 " http://localhost:${PORT_DEV_PROXY} /login"
@@ -347,17 +313,10 @@ responds_with \
347313 " Envoy single page app example" \
348314 " https://localhost:${PORT_PROXY} " \
349315 -k
350- if [[ " $SUPPORT_PKCE " == " true" ]]; then
351- responds_with_header \
352- " location: https://github.com/login/oauth/authorize?client_id=XXX&code_challenge=[A-Za-z0-9_-]\{1,\}&code_challenge_method=S256&redirect_uri=https%3A%2F%2Flocalhost%3A${PORT_PROXY} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
353- " https://localhost:${PORT_PROXY} /login" \
354- -k
355- else
356- responds_with_header \
357- " location: https://github.com/login/oauth/authorize?client_id=XXX&redirect_uri=https%3A%2F%2Flocalhost%3A${PORT_PROXY} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
358- " https://localhost:${PORT_PROXY} /login" \
359- -k
360- fi
316+ responds_with_header \
317+ " location: https://github.com/login/oauth/authorize?client_id=XXX&code_challenge=[A-Za-z0-9_-]\{1,\}&code_challenge_method=S256&redirect_uri=https%3A%2F%2Flocalhost%3A${PORT_PROXY} %2Fauthorize&response_type=code&scope=user%3Aemail&state=[A-Za-z0-9_-]\{1,\}" \
318+ " https://localhost:${PORT_PROXY} /login" \
319+ -k
361320responds_with_header \
362321 " set-cookie: OauthNonce=" \
363322 " https://localhost:${PORT_PROXY} /login" \
0 commit comments