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
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jan 7, 2025
1 parent 11635f9 commit 01bffaf
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;

Check failure on line 89 in src/Workbench/Workbench.php

View workflow job for this annotation

GitHub Actions / PHP:8.2 Code Analysis

Using nullsafe method call on non-nullable type Orchestra\Testbench\Contracts\Config. Use -> instead.

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 01bffaf

Please sign in to comment.