Giter Club home page Giter Club logo

Comments (17)

TheOneWithTheBraid avatar TheOneWithTheBraid commented on August 19, 2024 1

In my case (unsure whether exactly related), this happened when I tried to add the same U2F device several times. In infinitely hanged without an error message.

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024 1

I've added dome debugging prints to the code to check the values, and when the payload for POST request is:

image

The $arguments variable looks like this right before call to call_user_func_array():

[NULL, NULL, "yubikey"]

Where yubikey is the $name passed to finishRegister():

	public function finishRegister(string $registrationData, string $clientData, string $name = null): JSONResponse {
		return new JSONResponse($this->manager->finishRegistration($this->userSession->getUser(), $registrationData, $clientData, $name));
	}

So we're clearly missing $registrationData and $clientData.

from twofactor_u2f.

ChristophWurst avatar ChristophWurst commented on August 19, 2024

See #690

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

I'm seeing the same issue, endless spinning and the error:

OCA\TwoFactorU2F\Controller\SettingsController::finishRegister():
Argument #1 ($registrationData) must be of type string, null given,
called in /var/www/html/lib/private/AppFramework/Http/Dispatcher.php
on line 217 in file /var/www/html/custom_apps/twofactor_u2f/lib/Controller/SettingsController.php line 65

And I already have overwriteprotocol: https set, so that's not it.

 > php occ config:list | jq .system.overwriteprotocol
"https"

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

I can see the request to /index.php/apps/twofactor_u2f/settings/finishregister being made:

image

And the payload is there:

image

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

We can see saveRegistrationData is called from the AddDeviceDialog:

saveRegistrationData () {
const data = this.registrationData
data.name = this.name
logger.debug('saving registration data', {data})
return finishRegistration(data)
.then(device => this.$store.commit('addDevice', device))
.then(logAndPass('new device added to store'))
.catch(err => {
logger.error('Error persisting registration', err)
throw new Error(t('twofactor_u2f', 'Server error while trying to complete U2F device registration'))
})
},

Which created a data object with the name attribute set to what the user provides, which then is sent via:
export function finishRegistration (data) {
const url = generateUrl('/apps/twofactor_u2f/settings/finishregister')
return Axios.post(url, data)
.then(resp => resp.data)
}

To the /apps/twofactor_u2f/settings/finishregister endpoint. Which we can see happened above, as expected.

So the issue probably isn't on the frontend, meaning Vue/JS side.

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

This is the full error btw: https://gist.github.com/jakubgs/951909e3253baf46cc54e5a9521b255d

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

These three issues seem related:

They all include the must be of type string, null given error caused somewhere in the stack trace by lib/private/AppFramework/Http/Dispatcher.php, which seems to indicate the payload is lost somewhere along the way..

from twofactor_u2f.

aikitori avatar aikitori commented on August 19, 2024

I can't add a new WebAuthn device. Is this related or should i open a new issue?

Browser Log (Firefox):

starting webauthn registration AddDevice.vue:158
[DEBUG] settings: confirmed password 
Object { app: "settings", uid: "user" }
ConsoleLogger.js:29:16
XHRPOSThttps://cloud.example.com/settings/api/personal/webauthn/registration
[HTTP/2 500 Internal Server Error 141ms]

[ERROR] settings: Error persisting webauthn registration 
Object { app: "settings", uid: "user", error: Error }
ConsoleLogger.js:41:16
Error: Server-Fehler beim Versuch die WebAuthn-Geräte-Registrierung abzuschließen
    e AddDevice.vue:195
    u runtime.js:63
    _invoke runtime.js:294
    v runtime.js:119
    x vue-settings-personal-webauthn.js:223
    s vue-settings-personal-webauthn.js:223
    promise callback*x vue-settings-personal-webauthn.js:223
    a vue-settings-personal-webauthn.js:223
    saveRegistrationData vue-settings-personal-webauthn.js:223
    saveRegistrationData vue-settings-personal-webauthn.js:223
    saveRegistrationData vue-settings-personal-webauthn.js:223
    promise callback*submit AddDevice.vue:179
    VueJS 28
    start AddDevice.vue:116
    promise callback*start AddDevice.vue:116
    VueJS 2
AddDevice.vue:183

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

When I put a debug line here:

			$this->logger->info("WTF param: $param -> '$value' ($type)");

I can see that the arguments are all of type string but the first two are empty strings:

WTF param: registrationData -> '' (string)
WTF param: clientData -> '' (string)
WTF param: name -> 'yubikey' (string)

But then the first two empty strings somehow get turned into NULLs.

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

Specifically, I printed contents of $arguments before and after this line:
https://github.com/nextcloud/server/blob/v23.0.3/lib/private/AppFramework/Http/Dispatcher.php#L214

And it appears that the empty string in $value turns into NULL the moment this assignment in the loop takes place:

			$arguments[] = $value;

Which as far as I can tell should not be happening:
https://user-images.githubusercontent.com/2212681/159962326-04aa86cd-79ba-4c5d-9864-c1f621f4dedd.png

But I lack the context to know if these should even be empty strings in the first place.

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

@ChristophWurst sorry for pinging you directly but I'd appreciate some insight here.

What are the expected values for $registrationData and $clientData? I assume it's not NULL, but is empty string valid?
My guess would be that no, but I lack the context to know what should be in those variables.

Are those variables supposed to be present in the JSON that is POSTed to the finishregister endpint?
If so then the issue must be on the client side since those are not visible when looking up the request in browser dev console.

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

Based on these lines it appears that the registrationData should contains something more:

saveRegistrationData () {
const data = this.registrationData
data.name = this.name

Correct?

So that would mean the issue is somewhere in the frontend JS?
Or maybe the issue is the browser not providing this data?

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

It appears to me that if something went wrong on client side we should see this error here:

getRegistrationData () {
return startRegistration()
.catch(err => {
logger.error('Error getting u2f registration data from server', err)
throw new Error(t('twofactor_u2f', 'Server error while trying to add U2F device'))
})
},

But instead what I get is:

Uncaught (in promise) Error: U2F device registration failed (error code unknown)
    at a.rejectRegistration (AddDeviceDialog.vue:157:1)
    at AddDeviceDialog.vue:135:1

Though I can see that there is a payload sent to the startregister endpoint:

image

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

And the error appears to be handled by this case:

default:
// 1 - OTHER_ERROR
// 2 - BAD_REQUEST
// 3 - CONFIGURATION_UNSUPPORTED
Promise.reject(new Error(t('twofactor_u2f', 'U2F device registration failed (error code {errorCode})', {
errorCode: data.errorCode || 'unknown'
})));

The errorCode being the unknown fallback doesn't help debug this.

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

I think the key to this issue is this error:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('chrome-extension://kmendfapggjehodndflmmgagdbamhnfd') does not match the recipient window's origin ('null').
(anonymous) @ generated-google-u2f-api.js:534
load (async)
r.getIframePort_ @ generated-google-u2f-api.js:532
(anonymous) @ generated-google-u2f-api.js:206

Which is described here:

But the thing is I already have overwriteprotocol: https set, as well as some other related settings:

  'overwrite.cli.url' => 'https://localhost',
  'overwritehost' => 'cloud.example.org',
  'overwriteprotocol' => 'https',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'cloud.example.org',
    2 => 'onlyoffice.example.org',
  ),
  'trusted_proxies' => 
  array (
    0 => '127.0.0.1',
    1 => '10.0.0.0/8',
    2 => '172.17.0.0/16',
  ),

But something is still missing. Maybe my trusted_proxies are incorrect.

from twofactor_u2f.

jakubgs avatar jakubgs commented on August 19, 2024

I'm starting to think the most sensible thing is to just disable U2F extension in favor of WebAuthN since U2F is deprecated.

Because I really can't get this to work no matter how I change my reverse proxy setup.

from twofactor_u2f.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.