Skip to content

Commit

Permalink
Fixes #1751 - Add error thrown if APP_URL does not match current url (#…
Browse files Browse the repository at this point in the history
…1985)

Co-authored-by: Martin Stone <1611702+d7415@users.noreply.github.com>
  • Loading branch information
ildyria and d7415 authored Aug 24, 2023
1 parent d7d0b5f commit 3dd7dcc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Actions/Diagnostics/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Actions\Diagnostics;

use App\Actions\Diagnostics\Pipes\Checks\AdminUserExistsCheck;
use App\Actions\Diagnostics\Pipes\Checks\AppUrlMatchCheck;
use App\Actions\Diagnostics\Pipes\Checks\BasicPermissionCheck;
use App\Actions\Diagnostics\Pipes\Checks\ConfigSanityCheck;
use App\Actions\Diagnostics\Pipes\Checks\DBIntegrityCheck;
Expand Down Expand Up @@ -32,6 +33,7 @@ class Errors
GDSupportCheck::class,
ImageOptCheck::class,
IniSettingsCheck::class,
AppUrlMatchCheck::class,
MigrationCheck::class,
PHPVersionCheck::class,
TimezoneCheck::class,
Expand Down
24 changes: 24 additions & 0 deletions app/Actions/Diagnostics/Pipes/Checks/AppUrlMatchCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Actions\Diagnostics\Pipes\Checks;

use App\Contracts\DiagnosticPipe;

class AppUrlMatchCheck implements DiagnosticPipe
{
/**
* {@inheritDoc}
*/
public function handle(array &$data, \Closure $next): array
{
$config_url = config('app.url');
// https:// is 8 characters.
if (strpos($config_url, '/', 8) !== false) {
$data[] = 'Warning: APP_URL contains a sub-path. This may impact your WebAuthn authentication.';
} elseif ($config_url !== request()->httpHost() && $config_url !== request()->schemeAndHttpHost()) {
$data[] = 'Error: APP_URL does not match the current url. This will break WebAuthn authentication. Please update APP_URL to reflect this change.';
}

return $next($data);
}
}

0 comments on commit 3dd7dcc

Please sign in to comment.