]> _ Git - fluidbook-hosting.git/commitdiff
wip #4184 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 18 Jan 2021 15:18:56 +0000 (16:18 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 18 Jan 2021 15:18:56 +0000 (16:18 +0100)
LVMH-SSO/_secure.php

index 9ca3ed540aac8b35a6e4b6adcc0a99b77fdf7fac..13e59154023eb3bb922e8c59c3ad6e6db6f0a74d 100644 (file)
@@ -1,4 +1,9 @@
 <?php
+$t = md5(rand(0, 10000000));
+if (isset($_REQUEST)) {
+    file_put_contents(__DIR__.'/log/log.' . $t . '.log', print_r($_REQUEST, true));
+}
+
 $basedir = '/LVMH/Internal-Control-Base-December-2020/';
 $base = 'https://hosting.fluidbook.com' . $basedir;
 
@@ -93,6 +98,7 @@ if ($needsAuth) {
             ],
             'x509cert' => $metadata['EntityDescriptor']['md:IDPSSODescriptor']['md:KeyDescriptor']['ds:KeyInfo']['ds:X509Data']['ds:X509Certificate'],
         ]];
+
     try {
         $auth = new \OneLogin\Saml2\Auth($samlsettings);
     } catch (Exception $e) {
@@ -101,10 +107,11 @@ if ($needsAuth) {
     }
 
     if (!empty($_REQUEST['SAMLResponse']) && !empty($_REQUEST['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();
@@ -223,13 +230,13 @@ function getMetadata()
     $limit = time() - 3600;
     $cachefile = __DIR__ . '/_metadata';
 
-    if (!file_exists($cachefile) || filesize($cachefile)<=20 || filemtime($cachefile) < $limit) {
+    if (!file_exists($cachefile) || filesize($cachefile) <= 20 || filemtime($cachefile) < $limit) {
         $xml = simplexml_load_string(file_get_contents('https://okta.lvmh.com/app/exkde2eh6L55wyfcE416/sso/saml/metadata'));
         $metadata = xmlToArray($xml);
         file_put_contents($cachefile, json_encode($metadata));
         return $metadata;
     } else {
-        return json_decode(file_get_contents($cachefile));
+        return json_decode(file_get_contents($cachefile), true);
     }
 
 }
\ No newline at end of file