Skip to content

Commit 6ca3fbc

Browse files
feat: add option to enable and disable login route (#13)
1 parent 44e7078 commit 6ca3fbc

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

config/oidc.php

+16
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,26 @@
5353
* Route configuration
5454
*/
5555
'route_configuration' => [
56+
/**
57+
* Enable or disable the login route.
58+
*/
59+
'enabled' => env('OIDC_LOGIN_ROUTE_ENABLED', true),
60+
61+
/**
62+
* The url of the login route.
63+
*/
5664
'login_route' => env('OIDC_LOGIN_ROUTE', '/oidc/login'),
65+
66+
/**
67+
* The middleware that runs on the login route.
68+
*/
5769
'middleware' => [
5870
'web'
5971
],
72+
73+
/**
74+
* The prefix of the login route.
75+
*/
6076
'prefix' => '',
6177
]
6278
];

src/OpenIDConnectServiceProvider.php

+19
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function boot(): void
4242

4343
protected function registerRoutes(): void
4444
{
45+
if (!$this->routesEnabled()) {
46+
return;
47+
}
48+
4549
Route::group($this->routeConfiguration(), function () {
4650
$this->loadRoutesFrom(__DIR__ . '/../routes/oidc.php');
4751
});
@@ -60,6 +64,21 @@ protected function routeConfiguration(): array
6064
];
6165
}
6266

67+
/**
68+
* Check in config if the routes are enabled.
69+
*
70+
* @return bool
71+
*/
72+
protected function routesEnabled(): bool
73+
{
74+
$enabled = config('oidc.route_configuration.enabled');
75+
if (!is_bool($enabled)) {
76+
return false;
77+
}
78+
79+
return $enabled;
80+
}
81+
6382
protected function registerConfigurationLoader(): void
6483
{
6584
$this->app->singleton(OpenIDConfigurationLoader::class, function (Application $app) {

0 commit comments

Comments
 (0)