From 2b6f22bc67568d70a71c88e0bd55a5ac30e7d423 Mon Sep 17 00:00:00 2001 From: Marcel Wege Date: Sat, 4 Mar 2023 10:18:59 +0100 Subject: [PATCH] feat(sp): add valid until date to sp configuration --- .gitignore | 1 + config/saml2.php | 7 +++++++ src/Auth.php | 4 ++-- src/Http/Controllers/Saml2Controller.php | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5826402..38cdbd7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.phar composer.lock .DS_Store +.idea \ No newline at end of file diff --git a/config/saml2.php b/config/saml2.php index fae987d..5b15fc1 100644 --- a/config/saml2.php +++ b/config/saml2.php @@ -214,6 +214,13 @@ 'singleLogoutService' => [ 'url' => '' ], + + /* + * Valid Until (in seconds) + * Default value will be 30 days + * + */ + 'validUntil' => 2592000, ], /* diff --git a/src/Auth.php b/src/Auth.php index ce94894..80781c1 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -184,10 +184,10 @@ public function sls($retrieveParametersFromServer = false) * @throws \Exception * @throws \InvalidArgumentException If metadata is not correctly set */ - public function getMetadata() + public function getMetadata($validUntil = null) { $settings = $this->base->getSettings(); - $metadata = $settings->getSPMetadata(); + $metadata = $settings->getSPMetadata(false, $validUntil); $errors = $settings->validateMetadata($metadata); if (!count($errors)) { diff --git a/src/Http/Controllers/Saml2Controller.php b/src/Http/Controllers/Saml2Controller.php index edd4962..a7a821d 100644 --- a/src/Http/Controllers/Saml2Controller.php +++ b/src/Http/Controllers/Saml2Controller.php @@ -26,7 +26,8 @@ class Saml2Controller extends Controller */ public function metadata(Auth $auth) { - $metadata = $auth->getMetadata(); + $validUntil = config('saml2.sp.validUntil'); + $metadata = $auth->getMetadata($validUntil); return response($metadata, 200, ['Content-Type' => 'text/xml']); }