Auth CAS: keep URL parameters in CAS callback URL

This commit is contained in:
Benjamin Renard 2023-11-20 16:40:11 +01:00
parent c71109124c
commit fbd24ff1b9
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC
2 changed files with 15 additions and 17 deletions

View file

@ -103,12 +103,11 @@ class Cas extends Method {
* @return string * @return string
*/ */
private static function get_cas_callback_url() { private static function get_cas_callback_url() {
return Url :: get_absolute_url( return Url :: add_url_parameter(
'login/cas_callback?next='.( Url :: get_absolute_url('login/cas_callback'),
isset($_REQUEST['next'])? 'next',
$_REQUEST['next']: isset($_REQUEST['next'])?$_REQUEST['next']:urlencode(Url :: get_current_url(true)),
urlencode(Url :: get_current_url()) false
)
); );
} }

View file

@ -332,9 +332,11 @@ class Url {
/** /**
* Retreive current requested URL and return it * Retreive current requested URL and return it
* *
* @param bool $with_parameters Set to true to retreive current URL with GET parameters
*
* @return string|false The current request URL or false if fail * @return string|false The current request URL or false if fail
**/ **/
public static function get_current_url() { public static function get_current_url($with_parameters=false) {
Log :: trace("URL : request URI = '".$_SERVER['REQUEST_URI']."'"); Log :: trace("URL : request URI = '".$_SERVER['REQUEST_URI']."'");
$base = self :: get_rewrite_base(); $base = self :: get_rewrite_base();
@ -351,16 +353,13 @@ class Url {
$current_url = substr($_SERVER['REQUEST_URI'], strlen($base)); $current_url = substr($_SERVER['REQUEST_URI'], strlen($base));
if (!$with_parameters) {
// URL contain params ? // URL contain params ?
$params_start = strpos($current_url, '?'); $params_start = strpos($current_url, '?');
if ($params_start !== false) if ($params_start !== false)
// Params detected, remove it // Params detected, remove it
$current_url = substr($current_url, 0, $params_start);
// No url / currrent url start by '?' ? }
if ($params_start == 0)
return '';
else
return substr($current_url, 0, $params_start);
return $current_url; return $current_url;
} }