ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SAML1.php
Go to the documentation of this file.
1<?php
3
10{
16 public static function sendResponse(array $state)
17 {
18 assert(isset($state['Attributes']));
19 assert(isset($state['SPMetadata']));
20 assert(isset($state['saml:shire']));
21 assert(array_key_exists('saml:target', $state)); // Can be NULL
22
23 $spMetadata = $state["SPMetadata"];
24 $spEntityId = $spMetadata['entityid'];
26 '$metadata[' . var_export($spEntityId, true) . ']');
27
28 SimpleSAML\Logger::info('Sending SAML 1.1 Response to ' . var_export($spEntityId, true));
29
30 $attributes = $state['Attributes'];
31 $shire = $state['saml:shire'];
32 $target = $state['saml:target'];
33
35
36 $idpMetadata = $idp->getConfig();
37
40
41 $statsData = array(
42 'spEntityID' => $spEntityId,
43 'idpEntityID' => $idpMetadata->getString('entityid'),
44 'protocol' => 'saml1',
45 );
46 if (isset($state['saml:AuthnRequestReceivedAt'])) {
47 $statsData['logintime'] = microtime(true) - $state['saml:AuthnRequestReceivedAt'];
48 }
49 SimpleSAML_Stats::log('saml:idp:Response', $statsData);
50
51 // Generate and send response.
52 $ar = new \SimpleSAML\XML\Shib13\AuthnResponse();
53 $authnResponseXML = $ar->generate($idpMetadata, $spMetadata, $shire, $attributes);
54
55 $httppost = new HTTPPost($config, $metadata);
56 $httppost->sendResponse($authnResponseXML, $idpMetadata, $spMetadata, $target, $shire);
57 }
58
59
65 public static function receiveAuthnRequest(SimpleSAML_IdP $idp)
66 {
67 if (isset($_REQUEST['cookieTime'])) {
68 $cookieTime = (int)$_REQUEST['cookieTime'];
69 if ($cookieTime + 5 > time()) {
70 /*
71 * Less than five seconds has passed since we were
72 * here the last time. Cookies are probably disabled.
73 */
75 }
76 }
77
78 if (!isset($_REQUEST['providerId'])) {
79 throw new SimpleSAML_Error_BadRequest('Missing providerId parameter.');
80 }
81 $spEntityId = (string)$_REQUEST['providerId'];
82
83 if (!isset($_REQUEST['shire'])) {
84 throw new SimpleSAML_Error_BadRequest('Missing shire parameter.');
85 }
86 $shire = (string)$_REQUEST['shire'];
87
88 if (isset($_REQUEST['target'])) {
89 $target = $_REQUEST['target'];
90 } else {
91 $target = null;
92 }
93
94 SimpleSAML\Logger::info('Shib1.3 - IdP.SSOService: Got incoming Shib authnRequest from ' . var_export($spEntityId, true) . '.');
95
97 $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'shib13-sp-remote');
98
99 $found = false;
100 foreach ($spMetadata->getEndpoints('AssertionConsumerService') as $ep) {
101 if ($ep['Binding'] !== 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post') {
102 continue;
103 }
104 if ($ep['Location'] !== $shire) {
105 continue;
106 }
107 $found = true;
108 break;
109 }
110 if (!$found) {
111 throw new Exception('Invalid AssertionConsumerService for SP ' .
112 var_export($spEntityId, true) . ': ' . var_export($shire, true));
113 }
114
115 SimpleSAML_Stats::log('saml:idp:AuthnRequest', array(
116 'spEntityID' => $spEntityId,
117 'protocol' => 'saml1',
118 ));
119
120 $sessionLostURL = \SimpleSAML\Utils\HTTP::addURLParameters(
121 \SimpleSAML\Utils\HTTP::getSelfURL(),
122 array('cookieTime' => time()));
123
124 $state = array(
125 'Responder' => array('sspmod_saml_IdP_SAML1', 'sendResponse'),
126 'SPMetadata' => $spMetadata->toArray(),
127 SimpleSAML_Auth_State::RESTART => $sessionLostURL,
128 'saml:shire' => $shire,
129 'saml:target' => $target,
130 'saml:AuthnRequestReceivedAt' => microtime(true),
131 );
132
133 $idp->handleAuthenticationRequest($state);
134 }
135}
$metadata['__DYNAMIC:1__']
$spEntityId
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
An exception for terminatinating execution or to throw for unit testing.
static info($string)
Definition: Logger.php:199
static checkSessionCookie($retryURL=null)
Check for session cookie, and show missing-cookie page if it is missing.
Definition: HTTP.php:286
const RESTART
The index in the state array which contains the restart URL.
Definition: State.php:57
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
static getByState(array &$state)
Retrieve the IdP "owning" the state.
Definition: IdP.php:145
static getMetadataHandler()
This function retrieves the current instance of the metadata handler.
static log($event, array $data=array())
Notify about an event.
Definition: Stats.php:71
static receiveAuthnRequest(SimpleSAML_IdP $idp)
Receive an authentication request.
Definition: SAML1.php:65
static sendResponse(array $state)
Send a response to the SP.
Definition: SAML1.php:16
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
$config
Definition: bootstrap.php:15
$idpMetadata
$spMetadata
$target
Definition: test.php:19
Attribute-related utility methods.
$idp
Definition: prp.php:13