From 1333e97cbd85c3b983b25ffad01ac3dbc4829557 Mon Sep 17 00:00:00 2001 From: Walid Date: Wed, 20 Oct 2021 15:28:20 +0200 Subject: [PATCH] Strip whitespace before certificate cleanup (#72) * Strip whitespace before certificate cleanup This insures that the certificate preg_replace cleanup works as expected * Add guards to samlidp config file This fixes the following issue: ErrorException thrown with message in_array() expects parameter 2 to be array, null given ErrorException in: /app/vendor/codegreencreative/laravel-samlidp/src/Listeners/SamlLogout.php:19 * code cleanup Co-authored-by: Walid Aqleh --- config/samlidp.php | 5 ++++- src/Http/Controllers/MetadataController.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/samlidp.php b/config/samlidp.php index 9d4ee9f..8126211 100644 --- a/config/samlidp.php +++ b/config/samlidp.php @@ -46,5 +46,8 @@ // key is beginning of HTTP_REFERER value from SERVER, value is redirect path 'sp_slo_redirects' => [ // 'https://example.com' => 'https://example.com', - ] + ], + + // List of guards saml idp will catch Authenticated, Login and Logout events + 'guards' => ['web'] ]; diff --git a/src/Http/Controllers/MetadataController.php b/src/Http/Controllers/MetadataController.php index 365afd3..f1764b9 100644 --- a/src/Http/Controllers/MetadataController.php +++ b/src/Http/Controllers/MetadataController.php @@ -20,7 +20,7 @@ public function index() } $cert = Storage::disk('samlidp')->get(config('samlidp.certname', 'cert.pem')); - $cert = preg_replace('/^\W+\w+\s+\w+\W+\s(.*)\s+\W+.*$/s', '$1', $cert); + $cert = preg_replace('/^\W+\w+\s+\w+\W+\s(.*)\s+\W+.*$/s', '$1', trim($cert)); $cert = str_replace(PHP_EOL, "", $cert); return response(view('samlidp::metadata', compact('cert')), 200, [