diff --git a/ProcessMaker/Http/Controllers/Saml/MetadataController.php b/ProcessMaker/Http/Controllers/Saml/MetadataController.php new file mode 100644 index 0000000000..d0272ee7aa --- /dev/null +++ b/ProcessMaker/Http/Controllers/Saml/MetadataController.php @@ -0,0 +1,46 @@ +getValidUntil(); + $cacheDuration = $this->getCacheDuration(); + + View::share([ + 'saml_valid_until' => $validUntil, + 'saml_cache_duration' => $cacheDuration, + ]); + } + + /** + * The function returns the current date and time plus one year. + * + * @return the current date and time plus one year in the format 'Y-m-d\TH:i:s\Z'. + */ + protected function getValidUntil() + { + return date('Y-m-d\TH:i:s\Z', strtotime('+1 year')); + } + + /** + * The getCacheDuration function calculates the duration in seconds between the current time + * + * @return a string representing the duration in seconds + */ + protected function getCacheDuration() + { + $now = new DateTime(); + $oneMonthFromNow = new DateTime('+1 month'); + $interval = $now->diff($oneMonthFromNow); + $seconds = $interval->days * 24 * 60 * 60; + + return 'PT' . $seconds . 'S'; + } +} diff --git a/resources/views/vendor/samlidp/metadata.blade.php b/resources/views/vendor/samlidp/metadata.blade.php new file mode 100644 index 0000000000..58844777a2 --- /dev/null +++ b/resources/views/vendor/samlidp/metadata.blade.php @@ -0,0 +1,21 @@ +@php echo '' @endphp + + + + + + {{ $cert }} + + + + + + + {{ $cert }} + + + + urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress + + + diff --git a/routes/web.php b/routes/web.php index 9bdc56853a..de5d90882f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -30,6 +30,7 @@ use ProcessMaker\Http\Controllers\ProcessesCatalogueController; use ProcessMaker\Http\Controllers\ProfileController; use ProcessMaker\Http\Controllers\RequestController; +use ProcessMaker\Http\Controllers\Saml\MetadataController; use ProcessMaker\Http\Controllers\TaskController; use ProcessMaker\Http\Controllers\TemplateController; use ProcessMaker\Http\Controllers\TestStatusController; @@ -178,3 +179,6 @@ })->name('password-success'); Route::get('/unavailable', [UnavailableController::class, 'show'])->name('error.unavailable'); + +// SAML Metadata Route +Route::resource('/saml/metadata', MetadataController::class)->only('index');