From 3dd8a6efb3100f4c6ba9372778c63a74c566df96 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Thu, 10 Jul 2014 16:16:14 +0200 Subject: [PATCH] saml: Add total time of login operation to stats data. Add statistics data to saml:idp:Response and saml:idp:Response:error with the total time since we began processing the authentication request. --- modules/saml/lib/IdP/SAML1.php | 4 ++++ modules/saml/lib/IdP/SAML2.php | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/modules/saml/lib/IdP/SAML1.php b/modules/saml/lib/IdP/SAML1.php index ecac85d13..9ef95b78a 100644 --- a/modules/saml/lib/IdP/SAML1.php +++ b/modules/saml/lib/IdP/SAML1.php @@ -41,6 +41,9 @@ class sspmod_saml_IdP_SAML1 { 'idpEntityID' => $idpMetadata->getString('entityid'), 'protocol' => 'saml1', ); + if (isset($state['saml:AuthnRequestReceivedAt'])) { + $statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt']; + } SimpleSAML_Stats::log('saml:idp:Response', $statsData); /* Generate and send response. */ @@ -122,6 +125,7 @@ class sspmod_saml_IdP_SAML1 { 'saml:shire' => $shire, 'saml:target' => $target, + 'saml:AuthnRequestReceivedAt' => microtime(TRUE), ); $idp->handleAuthenticationRequest($state); diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php index 527a64078..e48b3eada 100644 --- a/modules/saml/lib/IdP/SAML2.php +++ b/modules/saml/lib/IdP/SAML2.php @@ -68,6 +68,9 @@ class sspmod_saml_IdP_SAML2 { 'idpEntityID' => $idpMetadata->getString('entityid'), 'protocol' => 'saml2', ); + if (isset($state['saml:AuthnRequestReceivedAt'])) { + $statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt']; + } SimpleSAML_Stats::log('saml:idp:Response', $statsData); /* Send the response. */ @@ -124,6 +127,9 @@ class sspmod_saml_IdP_SAML2 { 'protocol' => 'saml2', 'error' => $status, ); + if (isset($state['saml:AuthnRequestReceivedAt'])) { + $statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt']; + } SimpleSAML_Stats::log('saml:idp:Response:error', $statsData); $binding = SAML2_Binding::getBinding($protocolBinding); @@ -377,6 +383,7 @@ class sspmod_saml_IdP_SAML2 { 'saml:NameIDFormat' => $nameIDFormat, 'saml:AllowCreate' => $allowCreate, 'saml:Extensions' => $extensions, + 'saml:AuthnRequestReceivedAt' => microtime(TRUE), ); $idp->handleAuthenticationRequest($state); -- GitLab