sspmod_adfs_IdP_ADFS::receiveAuthnRequest PHP Method

receiveAuthnRequest() public static method

public static receiveAuthnRequest ( SimpleSAML_IdP $idp )
$idp SimpleSAML_IdP
    public static function receiveAuthnRequest(SimpleSAML_IdP $idp)
    {
        try {
            // accomodate for disfunctional $_GET "windows" slash decoding in PHP
            $wctx = $_GET['wctx'];
            foreach (explode('&', $_SERVER['REQUEST_URI']) as $e) {
                $a = explode('=', $e);
                if ($a[0] == 'wctx') {
                    $wctx = urldecode($a[1]);
                }
            }
            $requestid = $wctx;
            $issuer = $_GET['wtrealm'];
            $requestcache = array('RequestID' => $requestid, 'Issuer' => $issuer, 'RelayState' => $requestid);
            $spEntityId = $requestcache['Issuer'];
            $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
            $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'adfs-sp-remote');
            SimpleSAML\Logger::info('ADFS - IdP.prp: Incoming Authentication request: ' . $issuer . ' id ' . $requestid);
        } catch (Exception $exception) {
            throw new SimpleSAML_Error_Error('PROCESSAUTHNREQUEST', $exception);
        }
        $sessionLostURL = NULL;
        // TODO?
        $forceAuthn = FALSE;
        $isPassive = FALSE;
        $state = array('Responder' => array('sspmod_adfs_IdP_ADFS', 'sendResponse'), 'SPMetadata' => $spMetadata->toArray(), 'ForceAuthn' => $forceAuthn, 'isPassive' => $isPassive, 'adfs:wctx' => $wctx);
        $idp->handleAuthenticationRequest($state);
    }

Usage Example

Esempio n. 1
0
<?php

/**
 * ADFS PRP IDP protocol support for simpleSAMLphp.
 *
 * @author Hans Zandbelt, SURFnet bv, <*****@*****.**>
 * @package simpleSAMLphp
 */
SimpleSAML_Logger::info('ADFS - IdP.prp: Accessing ADFS IdP endpoint prp');
$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$idpEntityId = $metadata->getMetaDataCurrentEntityID('adfs-idp-hosted');
$idp = SimpleSAML_IdP::getById('adfs:' . $idpEntityId);
if (isset($_GET['wa'])) {
    if ($_GET['wa'] === 'wsignout1.0') {
        sspmod_adfs_IdP_ADFS::receiveLogoutMessage($idp);
    } else {
        if ($_GET['wa'] === 'wsignin1.0') {
            sspmod_adfs_IdP_ADFS::receiveAuthnRequest($idp);
        }
    }
    assert('FALSE');
} elseif (isset($_GET['assocId'])) {
    // logout response from ADFS SP
    $assocId = $_GET['assocId'];
    /* Association ID of the SP that sent the logout response. */
    $relayState = $_GET['relayState'];
    /* Data that was sent in the logout request to the SP. Can be null. */
    $logoutError = NULL;
    /* NULL on success, or an instance of a SimpleSAML_Error_Exception on failure. */
    $idp->handleLogoutResponse($assocId, $relayState, $logoutError);
}