Closed simplenotezy closed 6 years ago
Yes in fact /u2f/register route need en u2f authentication to access. Perhaps it's not the best idea...
If you want to allow an user to register a yubi key you need:
$router->get('/auth/u2f/whatever/register', [
'uses' => 'U2fController@registerData',
'as' => 'u2f.register.data',
'middleware' => 'auth' // <- not u2f
]);
$router->post('/auth/u2f/whatever/register', [
'uses' => 'U2fController@register',
'as' => 'u2f.register',
'middleware' => 'auth' // <- not u2f
]);
Correct method:
Route::get('/auth/u2f/register', [ 'uses' => '\Lahaxearnaud\U2f\Http\Controllers\U2fController@registerData', 'as' => 'u2f.register.data', 'middleware' => 'auth']);
Route::post('/auth/u2f/register', [ 'uses' => '\Lahaxearnaud\U2f\Http\Controllers\U2fController@register', 'as' => 'u2f.register', 'middleware' => 'auth']);
Before plugging in (and confirming) go to your network tab, enable preserve log, enable all types and then clear the logs out of your way... now plugin and confirm your device.
Laravel is probably returning 419 because there is no CSRF token in your form that is being submitted.
I had the same issue. The problem is that u2fController::register()
catches the root \Exception
and the app was throwing a QueryException
. Instead, it should only catch the particular exceptions that it would expect and let any other exceptions continue. Like this:
public function register(Request $request)
{
try {
$key = $this->u2f->doRegister(\Auth::user(), session('u2f.registerData'), json_decode($request->get('register')));
\Event::fire('u2f.register', [ 'u2fKey' => $key, 'user' => \Auth::user() ]);
session()->forget('u2f.registerData');
if ($this->config->get('u2f.register.postSuccessRedirectRoute')) {
return \Redirect::route($this->config->get('u2f.register.postSuccessRedirectRoute'));
} else {
return redirect('/');
}
} catch (\InvalidArgumentException $e) {
return \Redirect::route('u2f.register.data');
} catch (\u2flib_server\Error $e) {
return \Redirect::route('u2f.register.data');
}
}
I have now installed the library. How do I add my yubi key?
I assume I need to go to a route? Which? I have tried /u2f/auth and /u2f/register but both URLS redirect me to home.