Files
coolify/app/Http/Middleware/ConfigurePasskeys.php
Aditya Tripathi 7bed78c81e feat(auth): add passkey sign-in
Enable Fortify passkeys (laravel/passkeys) with the @laravel/passkeys
client. Users can sign in with a passkey, confirm sensitive actions with
one, and add, rename, and delete passkeys on the Profile page.

- Resolve the relying party for each request from the instance URL, then
  APP_URL, then localhost. Passkey routes return 404 on other hosts.
- Add the is_passkey_enabled instance setting (Settings > Advanced).
- Use a hex user handle (laravel/passkeys-server#41).
- Rate limit the passkey routes by client IP.
- Record audit events for registered, verified, and deleted passkeys.
2026-10-13 04:01:40 +00:00

29 lines
725 B
PHP

<?php
namespace App\Http\Middleware;
use App\Support\PasskeyRelyingParty;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class ConfigurePasskeys
{
public function handle(Request $request, Closure $next): Response
{
if (! $request->routeIs('passkey.*')) {
return $next($request);
}
$relyingParty = instanceSettings()->is_passkey_enabled ? PasskeyRelyingParty::resolve($request) : null;
abort_if($relyingParty === null, 404);
config([
'passkeys.relying_party_id' => $relyingParty['id'],
'passkeys.allowed_origins' => $relyingParty['origins'],
]);
return $next($request);
}
}