OneLogin_Saml2_Auth::processResponse PHP Method

processResponse() public method

Process the SAML Response sent by the IdP.
public processResponse ( string | null $requestId = null )
$requestId string | null The ID of the AuthNRequest sent by this SP to the IdP
    public function processResponse($requestId = null)
    {
        $this->_errors = array();
        if (isset($_POST) && isset($_POST['SAMLResponse'])) {
            // AuthnResponse -- HTTP_POST Binding
            $response = new OneLogin_Saml2_Response($this->_settings, $_POST['SAMLResponse']);
            if ($response->isValid($requestId)) {
                $this->_attributes = $response->getAttributes();
                $this->_nameid = $response->getNameId();
                $this->_nameidFormat = $response->getNameIdFormat();
                $this->_authenticated = true;
                $this->_sessionIndex = $response->getSessionIndex();
                $this->_sessionExpiration = $response->getSessionNotOnOrAfter();
            } else {
                $this->_errors[] = 'invalid_response';
                $this->_errorReason = $response->getError();
            }
        } else {
            $this->_errors[] = 'invalid_binding';
            throw new OneLogin_Saml2_Error('SAML Response not found, Only supported HTTP_POST Binding', OneLogin_Saml2_Error::SAML_RESPONSE_NOT_FOUND);
        }
    }

Usage Example

示例#1
0
 } else {
     if (isset($_GET['slo'])) {
         $returnTo = null;
         $paramters = array();
         $nameId = null;
         $sessionIndex = null;
         if (isset($_SESSION['samlNameId'])) {
             $nameId = $_SESSION['samlNameId'];
         }
         if (isset($_SESSION['samlSessionIndex'])) {
             $sessionIndex = $_SESSION['samlSessionIndex'];
         }
         $auth->logout($returnTo, $paramters, $nameId, $sessionIndex);
     } else {
         if (isset($_GET['acs'])) {
             $auth->processResponse();
             return;
             $errors = $auth->getErrors();
             if (!empty($errors)) {
                 print_r('<p>1' . implode(', ', $errors) . '</p>');
             }
             if (!$auth->isAuthenticated()) {
                 echo "<p>2 Not authenticated</p>";
                 exit;
             }
             $_SESSION['samlUserdata'] = $auth->getAttributes();
             $_SESSION['samlNameId'] = $auth->getNameId();
             $_SESSION['samlSessionIndex'] = $auth->getSessionIndex();
             if (isset($_POST['RelayState']) && OneLogin_Saml2_Utils::getSelfURL() != $_POST['RelayState']) {
                 $auth->redirectTo($_POST['RelayState']);
             }
All Usage Examples Of OneLogin_Saml2_Auth::processResponse