Skip to content

Commit 4b98580

Browse files
committed
temp fix
1 parent d070345 commit 4b98580

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

demo/app/Models/Passkey.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Casts\Attribute;
6+
use Spatie\LaravelPasskeys\Models\Passkey as SpatiePasskey;
7+
use Spatie\LaravelPasskeys\Support\Serializer;
8+
use Webauthn\CredentialRecord;
9+
10+
class Passkey extends SpatiePasskey
11+
{
12+
public function data(): Attribute
13+
{
14+
$serializer = Serializer::make();
15+
16+
return new Attribute(
17+
get: fn (string $value) => $serializer->fromJson(
18+
$value,
19+
CredentialRecord::class,
20+
),
21+
set: fn (CredentialRecord $value) => [
22+
'credential_id' => self::encodeCredentialId($value->publicKeyCredentialId),
23+
'data' => $serializer->toJson($value),
24+
],
25+
);
26+
}
27+
}

demo/config/passkeys.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
use App\Models\Passkey;
4+
use App\Models\User;
5+
use Spatie\LaravelPasskeys\Actions\ConfigureCeremonyStepManagerFactoryAction;
6+
use Spatie\LaravelPasskeys\Actions\FindPasskeyToAuthenticateAction;
7+
use Spatie\LaravelPasskeys\Actions\GeneratePasskeyAuthenticationOptionsAction;
8+
use Spatie\LaravelPasskeys\Actions\GeneratePasskeyRegisterOptionsAction;
9+
use Spatie\LaravelPasskeys\Actions\StorePasskeyAction;
10+
11+
return [
12+
/*
13+
* After a successful authentication attempt using a passkey
14+
* we'll redirect to this URL.
15+
*/
16+
'redirect_to_after_login' => '/dashboard',
17+
18+
/*
19+
* These class are responsible for performing core tasks regarding passkeys.
20+
* You can customize them by creating a class that extends the default, and
21+
* by specifying your custom class name here.
22+
*/
23+
'actions' => [
24+
'generate_passkey_register_options' => GeneratePasskeyRegisterOptionsAction::class,
25+
'store_passkey' => StorePasskeyAction::class,
26+
'generate_passkey_authentication_options' => GeneratePasskeyAuthenticationOptionsAction::class,
27+
'find_passkey' => FindPasskeyToAuthenticateAction::class,
28+
'configure_ceremony_step_manager_factory' => ConfigureCeremonyStepManagerFactoryAction::class,
29+
],
30+
31+
/*
32+
* These properties will be used to generate the passkey.
33+
*/
34+
'relying_party' => [
35+
'name' => config('app.name'),
36+
'id' => parse_url(config('app.url'), PHP_URL_HOST),
37+
'icon' => null,
38+
],
39+
40+
/*
41+
* The models used by the package.
42+
*
43+
* You can override this by specifying your own models
44+
*/
45+
'models' => [
46+
'passkey' => Passkey::class,
47+
'authenticatable' => env('AUTH_MODEL', User::class),
48+
],
49+
];

0 commit comments

Comments
 (0)