File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 'attributes_to_transfer ' => ['cn ' ],
3333 ],
3434 ],
35+ // Don't use php or SSP's built in methods for constructing queries. Default is false
36+ // Enabling this redirects the user back to the service with the exact service url provided.
37+ 'noReencode ' => false ,
3538
3639 'legal_target_service_urls ' => [
3740 //Any target service url string matching any of the following prefixes is accepted
Original file line number Diff line number Diff line change 3030 ],
3131 'http://changeTicketParam ' => [
3232 'ticketName ' => 'myTicket ' ,
33+ ],
34+ 'https://buggy.edu ' => [
35+ // Don't use php or SSP's built in methods for constructing queries.
36+ 'noReencode ' => true
3337 ]
3438 ],
3539
Original file line number Diff line number Diff line change @@ -227,6 +227,43 @@ public function testValidTicketNameOverride()
227227 );
228228 }
229229
230+ /**
231+ * Some clients don't correctly encode query parameters that are part their service
232+ * urls or encode a space in a different way then SSP will in a redirect. This workaround
233+ * is to allow those clients to work
234+ * @dataProvider buggyClientProvider
235+ * @return void
236+ */
237+ public function testBuggyClientBadUrlEncodingWorkAround ($ service_url )
238+ {
239+ $ this ->authenticate ();
240+
241+ /** @var array $resp */
242+ $ resp = $ this ->server ->get (
243+ self ::$ LINK_URL ,
244+ ['service ' => $ service_url ],
245+ [
246+ CURLOPT_COOKIEJAR => $ this ->cookies_file ,
247+ CURLOPT_COOKIEFILE => $ this ->cookies_file
248+ ]
249+ );
250+ $ this ->assertEquals (302 , $ resp ['code ' ]);
251+
252+ $ this ->assertStringStartsWith (
253+ $ service_url . '?ticket=ST- ' ,
254+ $ resp ['headers ' ]['Location ' ],
255+ 'Ticket should be part of the redirect. '
256+ );
257+ }
258+
259+ public function buggyClientProvider (): array
260+ {
261+ return [
262+ ['https://buggy.edu/kc/portal.do?solo&ct=Search%20Prot&curl=https://kc.edu/kc/IRB.do?se=1875*&runSearch=1 ' ],
263+ ['https://buggy.edu/kc ' ],
264+ ];
265+ }
266+
230267
231268 /**
232269 * Test outputting user info instead of redirecting
Original file line number Diff line number Diff line change 2828 * language
2929 */
3030
31+ use SimpleSAML \Configuration ;
32+ use SimpleSAML \Locale \Language ;
33+ use SimpleSAML \Logger ;
34+ use SimpleSAML \Module ;
3135use SimpleSAML \Module \casserver \Cas \AttributeExtractor ;
3236use SimpleSAML \Module \casserver \Cas \Protocol \SamlValidateResponder ;
3337use SimpleSAML \Module \casserver \Cas \ServiceValidator ;
3438use SimpleSAML \Module \casserver \Cas \Ticket \TicketFactory ;
3539use SimpleSAML \Module \casserver \Cas \Ticket \TicketStore ;
36- use SimpleSAML \Configuration ;
37- use SimpleSAML \Locale \Language ;
38- use SimpleSAML \Logger ;
39- use SimpleSAML \Module ;
4040use SimpleSAML \Session ;
4141use SimpleSAML \Utils \HTTP ;
4242
223223 echo '<pre> ' . htmlspecialchars ($ casResponse ) . '</pre> ' ;
224224 }
225225 } elseif ($ redirect ) {
226- HTTP ::redirectTrustedURL (HTTP ::addURLParameters ($ serviceUrl , $ parameters ));
226+ if ($ casconfig ->getBoolean ('noReencode ' , false )) {
227+ // Some client encode query params wrong, and calling HTTP::addURLParameters
228+ // will reencode them resulting in service mismatches
229+ $ extraParams = http_build_query ($ parameters );
230+ $ redirectUrl = $ _GET ['service ' ] . (strpos ('? ' , $ _GET ['service ' ]) === false ? '? ' : '& ' ) . $ extraParams ;
231+ HTTP ::redirectTrustedURL ($ redirectUrl );
232+ } else {
233+ HTTP ::redirectTrustedURL (HTTP ::addURLParameters ($ _GET ['service ' ], $ parameters ));
234+ }
227235 } else {
228236 HTTP ::submitPOSTData ($ serviceUrl , $ parameters );
229237 }
You can’t perform that action at this time.
0 commit comments