WebAuthn
WebAuthn copied to clipboard
[1.1.2] Routes namespace issue
PHP & Platform
8.1.6 - Windows 11
Database
MySQL 8.0.27
Laravel version
9.33.0
Have you done this?
- [X] I have checked my logs and I'm sure is a bug in this package.
- [X] I can reproduce this bug in isolation (vanilla Laravel install)
- [X] I can suggest a workaround as a Pull Request
Expectation
On new install, have in my /routes/web
use Laragear\WebAuthn\WebAuthn;
WebAuthn::routes();
When I try to use the register/options route, I get a 500 error
Description
In the log, I get this:
[2022-10-04 01:07:58] local.ERROR: Target class [App\Http\Controllers\App\Http\Controllers\WebAuthn\WebAuthnRegisterController] does not exist. {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [App\\Http\\Controllers\\App\\Http\\Controllers\\WebAuthn\\WebAuthnRegisterController] does not exist. at C:\\wamp\\www\\station\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php:877)
[stacktrace]
It appears that there is a namespacing issue because App\Http\Controllers is repeated.
For example, when I put the following in my web.php file, it works:
Route::controller(WebAuthnRegisterController::class)->middleware('web')->prefix('webauthn')->group(function () {
Route::post('register/options', 'options')->name('webauthn.register.options');
Route::post('register', 'register')->name('webauthn.register');
});
Route::controller(WebAuthnLoginController::class)->middleware('web')->prefix('webauthn')->group(function () {
Route::post('login/options', 'options')->name('webauthn.login.options');
Route::post('login', 'login')->name('webauthn.login');
});
Reproduction
As above
Stack trace & logs
as above
Gonna investigate. May be the method appends something that shouldn't.
Well, I coudln't find the culprit. I'll change the registration signature to set the controller action at registration time instead of using uses(), which should bypass the controller base namespace if you have one registered.