]> _ Git - fluidbook-hosting.git/commitdiff
wip #4184 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Jan 2021 10:50:16 +0000 (11:50 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Jan 2021 10:50:16 +0000 (11:50 +0100)
LVMH-SSO/_secure.php

index 13e59154023eb3bb922e8c59c3ad6e6db6f0a74d..8288667dec6616067d02d4b306e118e7e5db5bc2 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 $t = md5(rand(0, 10000000));
-if (isset($_REQUEST)) {
-    file_put_contents(__DIR__.'/log/log.' . $t . '.log', print_r($_REQUEST, true));
+if (isset($_POST) && count($_POST)) {
+    file_put_contents(__DIR__ . '/log/log.' . $t . '.log', print_r($_POST, true));
 }
 
 $basedir = '/LVMH/Internal-Control-Base-December-2020/';
@@ -18,7 +18,7 @@ foreach ($forbiddenext as $ext) {
 require_once "vendor/autoload.php";
 
 session_start();
-$needsAuth = empty($_SESSION['samlUserdata']);
+$needsAuth = !(isset($_SESSION['samlOK']) && $_SESSION['samlOK']);
 
 $file = $_SERVER['CONTEXT_DOCUMENT_ROOT'] . $_SERVER['SCRIPT_URL'];
 if (is_dir($file)) {
@@ -35,7 +35,7 @@ if ($needsAuth) {
     $samlsettings = [
         'sp' => [
             // Identifier of the SP entity  (must be a URI)
-            'entityId' => $url,
+            'entityId' => 'https://hosting.fluidbook.com/',
             // Specifies info about where and how the <AuthnResponse> message MUST be
             // returned to the requester, in this case our SP.
             'assertionConsumerService' => array(
@@ -106,15 +106,20 @@ if ($needsAuth) {
         die('an error occured');
     }
 
-    if (!empty($_REQUEST['SAMLResponse']) && !empty($_REQUEST['RelayState'])) {
+    if (!empty($_POST['SAMLResponse']) && !empty($_POST['RelayState'])) {
         $auth->processResponse(null);
 
         $errors = $auth->getErrors();
         if (empty($errors)) {
-            file_put_contents(__DIR__.'/log/err.' . $t . '.log', print_r($errors, true));
             // user has authenticated successfully
             $needsAuth = false;
             $_SESSION['samlUserdata'] = $auth->getAttributes();
+            $_SESSION['samlOK'] = true;
+            session_write_close();
+            file_put_contents(__DIR__ . '/log/ok.' . $t . '.log', print_r($_SESSION, true));
+            file_put_contents(__DIR__ . '/log/xml.' . $t . '.log', $auth->getLastResponseXML());
+        } else {
+            file_put_contents(__DIR__ . '/log/err.' . $t . '.log', print_r($errors, true) . "\n\n--\n\n" . print_r($auth->getLastErrorReason(), true) . "\n\n--\n\n" . print_r($auth->getLastErrorException(), true));
         }
     }