Skip to content

Commit 5576269

Browse files
committed
add configuration for domain
1 parent e2eeb7b commit 5576269

5 files changed

Lines changed: 41 additions & 6 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"config": {
3-
"version": "3.5"
3+
"version": "3.6"
44
},
55
"repositories": {
66
"spid-sp-access-button": {

setup/Setup.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static function setup(Event $event) {
2828
$_spOrganizationDisplayName = "Organization Display Name";
2929
$_spOrganizationURL = "https://www.organization.org";
3030
$_entityID = "https://localhost";
31+
$_spDomain = "localhost";
3132
$_acsIndex = 0;
3233
$_adminPassword = "admin";
3334
$_technicalContactName = "";
@@ -91,14 +92,42 @@ public static function setup(Event $event) {
9192
}
9293

9394
if (!isset($config['entityID'])) {
94-
echo "Please insert your EntityID (" .
95+
echo "Please insert your EntityID, must start with http:// or https:// (" .
9596
$colors->getColoredString($_entityID, "green") . "): ";
9697
$config['entityID'] = readline();
9798
if ($config['entityID'] == null || $config['entityID'] == "") {
9899
$config['entityID'] = $_entityID;
99100
}
100101
}
101102

103+
if (!isset($config['spDomain'])) {
104+
$lowerEntityId = strtolower($config['entityID']);
105+
106+
if(substr($lowerEntityId, 0, 8)==='https://') {
107+
$_spDomain = substr($config['entityID'], 8);
108+
}
109+
110+
if(substr($lowerEntityId, 0, 7)==='http://') {
111+
$_spDomain = substr($config['entityID'], 7);
112+
}
113+
114+
if(substr(strtolower($_spDomain), 0, 4)==='www.') {
115+
$_spDomain = substr($_spDomain, 4);
116+
}
117+
118+
119+
echo "Please insert your Service Provider Domain, without www. (" .
120+
$colors->getColoredString($_spDomain, "green") . "): ";
121+
$config['spDomain'] = readline();
122+
if ($config['spDomain'] == null || $config['spDomain'] == "") {
123+
$config['spDomain'] = $_spDomain;
124+
}
125+
126+
if($config['spDomain']!=$_spDomain) {
127+
echo $colors->getColoredString("WARNING: the EntityID must be related to organization's domain", "yellow");
128+
}
129+
}
130+
102131
if (!isset($config['spName'])) {
103132
echo "Please insert your Service Provider Name (" .
104133
$colors->getColoredString($_spName, "green") . "): ";
@@ -568,6 +597,7 @@ public static function setup(Event $event) {
568597
echo $colors->getColoredString("\nWeb root directory: " . $config['wwwDir'], "yellow");
569598
echo $colors->getColoredString("\nService Name: " . $config['serviceName'], "yellow");
570599
echo $colors->getColoredString("\nEntity ID: " . $config['entityID'], "yellow");
600+
echo $colors->getColoredString("\nService Provider Domain: " . $config['spDomain'], "yellow");
571601
echo $colors->getColoredString("\nService Provider Name: " . $config['spName'], "yellow");
572602
echo $colors->getColoredString("\nService Provider Description: " . $config['spDescription'], "yellow");
573603
echo $colors->getColoredString("\nOrganization Name: " . $config['spOrganizationName'], "yellow");
@@ -715,7 +745,8 @@ public static function setup(Event $event) {
715745
"{{TECHCONTACT_NAME}}" => "'" . $config['technicalContactName'] . "'",
716746
"{{TECHCONTACT_EMAIL}}" => "'" . $config['technicalContactEmail'] . "'",
717747
"{{ACSCUSTOMLOCATION}}" => "'" . $config['acsCustomLocation'] . "'",
718-
"{{SLOCUSTOMLOCATION}}" => "'" . $config['sloCustomLocation'] . "'"
748+
"{{SLOCUSTOMLOCATION}}" => "'" . $config['sloCustomLocation'] . "'",
749+
"{{SP_DOMAIN}}" => "'." . $config['spDomain'] . "'"
719750
);
720751
$template = file_get_contents($config['installDir'] . '/setup/config/config.tpl', true);
721752
$customized = str_replace(array_keys($vars), $vars, $template);

setup/config/config.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ $config = array(
339339
* Example:
340340
* 'session.cookie.domain' => '.example.org',
341341
*/
342-
'session.cookie.domain' => null,
342+
'session.cookie.domain' => {{SP_DOMAIN}},
343343

344344
/*
345345
* Set the secure flag in the cookie.

setup/simplesamlphp/saml2/src/SAML2/Response.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ public function __construct(DOMElement $xml = null)
114114

115115
// Disco non funziona, vedi pure AuthnRequest
116116
$state = State::loadState($stateID, 'saml:sp:sso', true);
117+
if($state==null) {
118+
throw new \Exception('State not found for id ' . $stateID);
119+
}
120+
117121
$req_authnContextClassRef = $state["saml:AuthnContextClassRef"];
118122
$req_authnContextComparison = $state["saml:AuthnContextComparison"];
119123
$res_authnContextClassRef = $authnContextClassRef[0]->nodeValue;

setup/simplesamlphp/simplesamlphp/modules/saml/lib/Message.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,14 +647,14 @@ public static function processResponse(
647647
$inResponseTo = $response->getInResponseTo();
648648

649649
/* SPID-PHP CUSTOM: strip spid-php */
650-
/*$stateID = substr($inResponseTo, 8);
650+
$stateID = substr($inResponseTo, 8);
651651

652652
$state = State::loadState($stateID, 'saml:sp:sso', true);
653653
if($state==null) {
654654
throw new SSP_Error\Exception(
655655
'State not found for ID '.$inResponseTo
656656
);
657-
}*/
657+
}
658658

659659
/* END SPID CUSTOM */
660660

0 commit comments

Comments
 (0)