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
*/
private static function get_cas_callback_url() {
return Url :: get_absolute_url(
'login/cas_callback?next='.(
isset($_REQUEST['next'])?
$_REQUEST['next']:
urlencode(Url :: get_current_url())
)
return Url :: add_url_parameter(
Url :: get_absolute_url('login/cas_callback'),
'next',
isset($_REQUEST['next'])?$_REQUEST['next']:urlencode(Url :: get_current_url(true)),
false
);
}

View file

@ -332,9 +332,11 @@ class Url {
/**
* 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
**/
public static function get_current_url() {
public static function get_current_url($with_parameters=false) {
Log :: trace("URL : request URI = '".$_SERVER['REQUEST_URI']."'");
$base = self :: get_rewrite_base();
@ -351,16 +353,13 @@ class Url {
$current_url = substr($_SERVER['REQUEST_URI'], strlen($base));
// URL contain params ?
$params_start = strpos($current_url, '?');
if ($params_start !== false)
// Params detected, remove it
// No url / currrent url start by '?' ?
if ($params_start == 0)
return '';
else
return substr($current_url, 0, $params_start);
if (!$with_parameters) {
// URL contain params ?
$params_start = strpos($current_url, '?');
if ($params_start !== false)
// Params detected, remove it
$current_url = substr($current_url, 0, $params_start);
}
return $current_url;
}