From bde9cd893284c44e364f9490629c76eef196ebce Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 18 Jan 2021 16:18:56 +0100 Subject: [PATCH] wip #4184 @3 --- LVMH-SSO/_secure.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/LVMH-SSO/_secure.php b/LVMH-SSO/_secure.php index 9ca3ed5..13e5915 100644 --- a/LVMH-SSO/_secure.php +++ b/LVMH-SSO/_secure.php @@ -1,4 +1,9 @@ $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 -- 2.39.5