OneLogin_Saml2_Utils::getSelfURL PHP Метод

getSelfURL() публичный статический Метод

Returns the URL of the current host + current view + query.
public static getSelfURL ( ) : string
Результат string
    public static function getSelfURL()
    {
        $selfURLhost = self::getSelfURLhost();
        $requestURI = '';
        if (!empty($_SERVER['REQUEST_URI'])) {
            $requestURI = $_SERVER['REQUEST_URI'];
            if ($requestURI[0] !== '/') {
                if (preg_match('#^https?:\\/\\/[^\\/]*(\\/.*)#i', $requestURI, $matches)) {
                    $requestURI = $matches[1];
                }
            }
        }
        $infoWithBaseURLPath = self::buildWithBaseURLPath($requestURI);
        if (!empty($infoWithBaseURLPath)) {
            $requestURI = $infoWithBaseURLPath;
        }
        return $selfURLhost . $requestURI;
    }

Usage Example

 function verificar_acceso($datos_iniciales = null)
 {
     $auth = $this->instanciar_pedido_onelogin();
     if (!is_null(toba::memoria()->get_parametro('acs'))) {
         //Se verifica la respuesta y se chequea la autenticacion
         $auth->processResponse();
         $this->verificar_errores_onelogin($auth);
         if (!$auth->isAuthenticated()) {
             throw new toba_error_autenticacion('No ha sido posible autenticar al usuario');
         }
         $this->set_atributos_usuario($auth->getAttributes());
         $id_usuario = $this->recuperar_usuario_toba();
         //Recupero usr y verifico existencia en toba, excepcion si no existe
         try {
             toba::manejador_sesiones()->login($id_usuario, 'foobar', $datos_iniciales);
             //La clave no importa porque se autentifica via token
         } catch (toba_reset_nucleo $e) {
             if (isset($_POST['RelayState']) && OneLogin_Saml2_Utils::getSelfURL() != $_POST['RelayState']) {
                 $auth->redirectTo($_POST['RelayState']);
             } else {
                 throw $e;
             }
         }
         return $id_usuario;
     } else {
         $this->procesar_logout($auth);
         //Se hace el redirect hacia el idp
         $parametros_url = array();
         if (isset($this->parametros_url) && is_array($this->parametros_url)) {
             $parametros_url = $this->parametros_url;
         }
         $auth->login($this->generar_url($parametros_url));
     }
 }
All Usage Examples Of OneLogin_Saml2_Utils::getSelfURL