From b9c0187a994bc58d3e625a53b5f7756bb2653c1b Mon Sep 17 00:00:00 2001 From: Thomas Holden Date: Wed, 24 Apr 2024 14:58:57 -0400 Subject: [PATCH] implement a saml2_controller config string which allows the user to extend the Saml2Controller, without needing to redefine all the routes. See https://github.com/aacotroneo/laravel-saml2/commit/34fe227c2683dd8ed2a2b439731bb5a1755841b7 for the original config that this is directly copying from --- config/saml2.php | 10 ++++++++++ src/Http/routes.php | 12 +++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config/saml2.php b/config/saml2.php index 541f9fb..9c3a726 100644 --- a/config/saml2.php +++ b/config/saml2.php @@ -137,6 +137,16 @@ 'proxyVars' => false, + /* + | (Optional) Which class implements the route functions. + | If left blank, defaults to this lib's controller (Slides\Saml2\Http\Controllers\Saml2Controller). + | If you need to extend Saml2Controller (e.g. to override the `login()` function to pass + | a `$returnTo` argument), this value allows you to pass your own controller, and have + | it used in the routes definition. + | + */ + 'saml2_controller' => '', + /* |-------------------------------------------------------------------------- | Service Provider configuration. diff --git a/src/Http/routes.php b/src/Http/routes.php index 90a23b3..75cc5b7 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -6,28 +6,30 @@ 'prefix' => config('saml2.routesPrefix'), 'middleware' => array_merge(['saml2.resolveTenant'], config('saml2.routesMiddleware')), ], function () { + $saml2_controller = config('saml2.saml2_controller', 'Slides\Saml2\Http\Controllers\Saml2Controller'); + Route::get('/{uuid}/logout', array( 'as' => 'saml.logout', - 'uses' => 'Slides\Saml2\Http\Controllers\Saml2Controller@logout', + 'uses' => $saml2_controller.'@logout', )); Route::get('/{uuid}/login', array( 'as' => 'saml.login', - 'uses' => 'Slides\Saml2\Http\Controllers\Saml2Controller@login', + 'uses' => $saml2_controller.'@login', )); Route::get('/{uuid}/metadata', array( 'as' => 'saml.metadata', - 'uses' => 'Slides\Saml2\Http\Controllers\Saml2Controller@metadata', + 'uses' => $saml2_controller.'@metadata', )); Route::post('/{uuid}/acs', array( 'as' => 'saml.acs', - 'uses' => 'Slides\Saml2\Http\Controllers\Saml2Controller@acs', + 'uses' => $saml2_controller.'@acs', )); Route::get('/{uuid}/sls', array( 'as' => 'saml.sls', - 'uses' => 'Slides\Saml2\Http\Controllers\Saml2Controller@sls', + 'uses' => $saml2_controller.'@sls', )); });