Laragear / WebAuthn

Authenticate users with Passkeys: fingerprints, patterns and biometric data.
MIT License
308 stars 37 forks source link

alias parameter not stored in database #29

Closed felix-exon closed 8 months ago

felix-exon commented 1 year ago

PHP & Platform

8.1.11 - Mac OS Ventura 13.2

Database

latest (docker)

Laravel version

9.19

Have you done this?

Expectation

alias should be reflected in the database but it is not.

Description

sadly the parameter seems to be dropped.

Reproduction

const register = event => {
    event.preventDefault()
    new WebAuthn().register({
        alias: 'some alias'
    }).then(response => alert('Registration successful!'));
};

alias is sent to the options request but dropped on the way to the register request.
stored credentials do not include the given alias.

vanilla backend as described in docs `WebAuthnRegisterController.php`:
```php
    public function options(AttestationRequest $request): Responsable
    {
        return $request
            ->fastRegistration()
//            ->userless()
//            ->allowDuplicates()
            ->toCreate();
    }

    public function register(AttestedRequest $request): Response
    {
        $request->save($request->input('alias'));
        return response()->noContent();
    }


### Stack trace & logs

_No response_
DarkGhostHunter commented 1 year ago

I'll have to check WebAuthn API to remember what is the purpose of the alias. AFICR, it's user-land to alias the credentials.

MordiSacks commented 1 year ago

you are passing a string to $request->save($request->input('alias')); you should pass an array $request->save(['alias' => $request->input('alias')]);