Skip to content

Commit c764fad

Browse files
authored
Merge pull request #716 from code16/passkeys
Passkeys
2 parents 6c4dda6 + 4e26bef commit c764fad

52 files changed

Lines changed: 2892 additions & 503 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,24 @@
3838
"laravel/pint": "^1.27",
3939
"mockery/mockery": "^1.5.0",
4040
"nunomaduro/collision": "^8.0",
41+
"orchestra/pest-plugin-testbench": "^4.1",
4142
"orchestra/testbench": "^9.0|^10.0|^11.0",
4243
"pestphp/pest": "^3.0|^4.0",
4344
"pestphp/pest-plugin-laravel": "^3.0|^4.0",
4445
"phpunit/phpunit": "^11.0|^12.0",
46+
"spatie/laravel-passkeys": "^1.0",
4547
"spatie/laravel-ray": "^1.26",
4648
"spatie/laravel-typescript-transformer": "^2.3",
4749
"spatie/typescript-transformer": "^2.2"
4850
},
51+
"suggest": {
52+
"spatie/laravel-passkeys": "Allows you to use passkey authentication (^1.0 is required).",
53+
"pragmarx/google2fa-laravel": "Allows you to use 2FA default TOTP command",
54+
"bacon/bacon-qr-code": "Allows you to use QR codes in default TOTP command"
55+
},
56+
"conflict": {
57+
"spatie/laravel-passkeys": "<1.0 || >=2.0"
58+
},
4959
"autoload": {
5060
"files": [
5161
"src/sharp_helper.php"

demo/app/Models/User.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
use Illuminate\Database\Eloquent\Relations\MorphOne;
88
use Illuminate\Foundation\Auth\User as Authenticatable;
99
use Illuminate\Notifications\Notifiable;
10+
use Spatie\LaravelPasskeys\Models\Concerns\HasPasskeys;
11+
use Spatie\LaravelPasskeys\Models\Concerns\InteractsWithPasskeys;
1012

11-
class User extends Authenticatable
13+
class User extends Authenticatable implements HasPasskeys
1214
{
1315
use HasFactory;
16+
use InteractsWithPasskeys;
1417
use Notifiable;
1518

1619
protected $guarded = [];

demo/app/Providers/DemoSharpServiceProvider.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ protected function configureSharp(SharpConfigBuilder $config): void
2323
->setSharpMenu(SharpMenu::class)
2424
->setThemeColor('#004c9b')
2525
->setThemeLogo(logoUrl: '/img/sharp/logo.svg', logoHeight: '1rem', faviconUrl: '/img/sharp/favicon-32x32.png')
26-
->enableImpersonation()
2726
->enableForgottenPassword()
2827
->setAuthCustomGuard('web')
28+
->enable2faCustom(Demo2faNotificationHandler::class)
29+
->enableLoginRateLimiting(maxAttempts: 3)
30+
->when(config('demo.enable_passkeys'),
31+
fn () => $config->enablePasskeys(),
32+
fn () => $config->enableImpersonation()
33+
)
2934
->setLoginAttributes('email', 'password')
3035
->setUserDisplayAttribute('name')
3136
->setUserAvatarAttribute(fn () => auth()->user()->avatar?->thumbnail(200))
32-
->enable2faCustom(Demo2faNotificationHandler::class)
33-
->enableLoginRateLimiting(maxAttempts: 3)
3437
->suggestRememberMeOnLoginForm()
3538
->appendMessageOnLoginForm(view('sharp._login-page-message'))
3639
->enableGlobalSearch(AppSearchEngine::class, 'Search for posts or authors...')

demo/app/Sharp/Profile/ProfileSingleShow.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use App\Sharp\Profile\Commands\Activate2faCommand;
66
use App\Sharp\Profile\Commands\ChangePasswordCommand;
77
use App\Sharp\Profile\Commands\Deactivate2faCommand;
8+
use Code16\Sharp\Auth\Passkeys\Entity\PasskeyEntity;
9+
use Code16\Sharp\Show\Fields\SharpShowEntityListField;
810
use Code16\Sharp\Show\Fields\SharpShowPictureField;
911
use Code16\Sharp\Show\Fields\SharpShowTextField;
1012
use Code16\Sharp\Show\Layout\ShowLayout;
@@ -25,7 +27,11 @@ protected function buildShowFields(FieldsContainer $showFields): void
2527
)
2628
->addField(
2729
SharpShowPictureField::make('avatar'),
28-
);
30+
)
31+
->when(config('demo.enable_passkeys'), fn () => $showFields->addField(
32+
SharpShowEntityListField::make(PasskeyEntity::class)
33+
->setLabel('Passkeys')
34+
));
2935
}
3036

3137
protected function buildShowLayout(ShowLayout $showLayout): void
@@ -35,7 +41,8 @@ protected function buildShowLayout(ShowLayout $showLayout): void
3541
$section
3642
->addColumn(6, fn (ShowLayoutColumn $column) => $column->withField('email'))
3743
->addColumn(6, fn (ShowLayoutColumn $column) => $column->withField('avatar'));
38-
});
44+
})
45+
->when(config('demo.enable_passkeys'))->addEntityListSection(PasskeyEntity::class);
3946
}
4047

4148
public function buildShowConfig(): void

demo/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"masterminds/html5": "^2.9",
1717
"pragmarx/google2fa": "^8.0",
1818
"spatie/image-optimizer": "^1.7",
19+
"spatie/laravel-passkeys": "^1.6",
1920
"spatie/laravel-translatable": "^6.13",
2021
"symfony/html-sanitizer": "^7.3",
2122
"technikermathe/blade-lucide-icons": "dev-l13-compatibility",

0 commit comments

Comments
 (0)