Skip to content

Commit

Permalink
[7.x] Prevent authentication route registrations when auth: false (#…
Browse files Browse the repository at this point in the history
…289)

* [7.x] Prevent authentication route registrations when `auth: false`

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Jan 7, 2025
1 parent ebc16de commit 7131084
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Concerns/InteractsWithWorkbench.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function getPackageProvidersUsingWorkbench($app): ?array
$hasAuthentication = $config?->getWorkbenchAttributes()['auth'] ?? false;
$providers = $config?->getExtraAttributes()['providers'] ?? [];

if ($hasAuthentication && class_exists('Orchestra\Workbench\AuthServiceProvider')) {
if ($hasAuthentication === true && class_exists('Orchestra\Workbench\AuthServiceProvider')) {
$providers[] = 'Orchestra\Workbench\AuthServiceProvider';
}

Expand Down
8 changes: 5 additions & 3 deletions src/Workbench/Workbench.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ public static function start(ApplicationContract $app, ConfigContract $config, a
*/
public static function startWithProviders(ApplicationContract $app, ConfigContract $config): void
{
static::start($app, $config, [
'Orchestra\Workbench\AuthServiceProvider',
$hasAuthentication = $config->getWorkbenchAttributes()['auth'] ?? false;

static::start($app, $config, array_filter([
$hasAuthentication === true && class_exists('Orchestra\Workbench\AuthServiceProvider') ? 'Orchestra\Workbench\AuthServiceProvider' : null,
'Orchestra\Workbench\WorkbenchServiceProvider',
]);
]));
}

/**
Expand Down

0 comments on commit 7131084

Please sign in to comment.