SimpleSAML_Auth_Simple::requireAuth PHP Method

requireAuth() public method

If the user is authenticated, this function returns immediately. If the user isn't authenticated, this function will authenticate the user with the authentication source, and then return the user to the current page. This function accepts an array $params, which controls some parts of the authentication. See the login() method for a description.
public requireAuth ( array $params = [] )
$params array Various options to the authentication request. See the documentation.
    public function requireAuth(array $params = array())
    {
        $session = SimpleSAML_Session::getSessionFromRequest();
        if ($session->isValid($this->authSource)) {
            // Already authenticated
            return;
        }
        $this->login($params);
    }

Usage Example

Example #1
1
 function procesarFormulario()
 {
     $saml_lib_path = '/var/simplesamlphp/lib/_autoload.php';
     require_once $saml_lib_path;
     // $aplication_base_url = 'http://10.20.0.38/splocal/';
     $aplication_base_url = $this->host . $this->site . '/';
     $source = 'SPcrono';
     // Fuente de autenticación definida en el authsources del SP
     $as = new SimpleSAML_Auth_Simple($source);
     // Se pasa como parametro la fuente de autenticación
     $login_params = array('ReturnTo' => $aplication_base_url . 'index.php');
     $as->requireAuth($login_params);
     return false;
 }
All Usage Examples Of SimpleSAML_Auth_Simple::requireAuth