Open ahuemmer opened 4 years ago
Seeing the same problem on our installation running Nextcloud 19.0.5.
Uncaught (in promise) Error: U2F device registration failed (error code unknown)
This is the important bit of information. @cogliostro do you see the same in the browser console?
Yes. But it seems to work in Firefox. It fails in MS Edge ( the new one ).
Also seems to work in Chrome.
Okay but @ahuemmer reported this as not working on Firefox. It could be two unrelated issues.
Also pay close attention to the logged error. Does it contain an error code?
"Exception":"TypeError","Message":"Argument 1 passed to OCA\TwoFactorU2F\Controller\SettingsController::finishRegister() must be of the type string, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 170"
This is not a server error https://github.com/nextcloud/twofactor_u2f/issues/789#issuecomment-732056807
Check the browser console for the u2f error code
I'm seeing the same errors in the console as @ahuemmer registered.
Uncaught (in promise) Error: U2F device registration failed (error code unknown) at a.rejectRegistration (AddDeviceDialog.vue:157) at AddDeviceDialog.vue:135
POST https://xfiles.nhn.no/apps/twofactor_u2f/settings/finishregister 500 (Internal Server Error)
[ERROR] twofactor_u2f: Error persisting registration {app: "twofactor_u2f", uid: "KENNETHV", config: {…}, request: XMLHttpRequest, response: {…}, …}
[ERROR] twofactor_u2f: Error: Server error while trying to complete U2F device registration {app: "twofactor_u2f", uid: "KENNETHV"}
error code unknown
I guess we should add a console.error
to https://github.com/nextcloud/twofactor_u2f/blob/27b330b5821e97cc1720172176a06a42cf4b6533/src/components/AddDeviceDialog.vue#L154-L159 so the original error is logged. Now it's impossible to find out what it was.
For my case, I discover the error start happen on this callback
https://example.org/apps/twofactor_u2f/settings/startregister
there I get a json where the appId has the URL scheme as http:// even tho I'm doing a request from a valid https://. My server has a good setup on https, I could connect with desktop clients on my nextcloud installation and the overview said everything is clear and green, no error on https where I could see.
Now, I force it tho and push my id on client side (so browser, not PHP directly) to be https, it made the request well but then, when I'm about to save and store my data this next callback.
https://xample.org/apps/twofactor_u2f/settings/finishregister
Is where I stop, since the class on \OCA\TwoFactorU2F\Service\U2FManager::finishRegistration
makes a call to \OCA\TwoFactorU2F\Service\U2FManager::getU2f
for some reason this code
private function getU2f(): U2F {
$url = $this->request->getServerProtocol() . '://' . $this->request->getServerHost();
return new U2F($url);
}
get the server protocol as http. I'm thinking is because my proxy server is behind a traefik reverse proxy where I call the port 80 on nginx and that pass it to the php-fpm as scheme http.
I'm going to force nginx to deliver the scheme https even on port 80 and come back with the result.
Hope this could provide some tracks on this matter.
Yes, this system variable that you could place on config.php did the trick
'overwriteprotocol' => ' https' ,
Now the appId has https: and when making the request the Yubikey could be added without issue if your browser detect you are on a valid SSL Cert, the php backend just need to be tricked.
Thank you, @killua99, for your investigation!
Unfortunately, this doesn't apply to my case, as I've always had the overwriteprotocol
setting set to https
as you suggested.
Btw https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/reverse_proxy_configuration.html is the docs page for reverse proxies if anyone wants to double-check their setups. That also covers the overwirteprotocol.
@ChristophWurst Should i add a note in README letting users know to use https?
Yes please :+1:
Steps to reproduce
Expected behaviour
U2F registration should succeed
Actual behaviour
No progress is shown in the browser. JavaScript and backend errors are displayed in the development tools (see below).
Server configuration
Operating system: Gentoo Linux
Web server: Nginx 1.18.0-r1
Database: MariaDB 10.4.13-r2
PHP version: 7.4.8-r1
Version: 19.0.1.1 (problem also occurred in the newest 18.x version)
Updated from an older version or fresh install: Updated (several step-by-step-updates beginning with version 14 or 15)
List of activated apps:
The content of config/config.php:
Client configuration
Browser: Firefox 79
Operating system: Windows 10
Logs
Web server error log
(No meaningful entries considering the problem.)
Server log (data/nextcloud.log)
Browser log
From the JavaScript console log:
Just after clicking on "Add U2F device", without any other actions:
After naming the device and clicking "Add":
and
The relevant requests I can see in the network tab:
startregister
, response (request body was empty), code200
:finishregister
, request:(No more content!) Response code was
500
with nextcloud standard 500 error page.Personal remarks
I see a big similarity to #622 and #690 here, but IMHO I have done everything right, following the instructions there (esp. the
overwriteprotocol
andoverwrite.cli.url
settings.The Nextcloud installation is served "directly" by the nginx, no proxy or anything in between.
In the Nextcloud admin tab, there are no open issues ("All checks passed.").
What I tried so far:
oc_twofactor
... tables in the db.No luck for now.
Any help would be greatly appreciated! :) Thanks in advance!