Skip to content

Commit

Permalink
feat: add webauthn cookie when registering a new key (#6952)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Oct 24, 2023
1 parent 91324dc commit 142de32
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/Listeners/WebauthnRegistered.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Listeners;

use Illuminate\Support\Facades\Cookie;
use LaravelWebauthn\Events\WebauthnRegister;

class WebauthnRegistered
{
/**
* Handle WebauthnRegister event.
*
* @return void
*/
public function handle(WebauthnRegister $event)
{
Cookie::queue('webauthn_remember', $event->webauthnKey->user_id, 60 * 24 * 30);
}
}
5 changes: 5 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
use App\Domains\Contact\ManageDocuments\Events\FileDeleted;
use App\Domains\Contact\ManageDocuments\Listeners\DeleteFileInStorage;
use App\Listeners\LoginListener;
use App\Listeners\WebauthnRegistered;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use LaravelWebauthn\Events\WebauthnRegister;
use SocialiteProviders\Azure\AzureExtendSocialite;
use SocialiteProviders\Facebook\FacebookExtendSocialite;
use SocialiteProviders\GitHub\GitHubExtendSocialite;
Expand Down Expand Up @@ -42,6 +44,9 @@ class EventServiceProvider extends ServiceProvider
LinkedInExtendSocialite::class,
TwitterExtendSocialite::class,
],
WebauthnRegister::class => [
WebauthnRegistered::class,
],
];

/**
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ parameters:

- message: '#Access to an undefined property App\\Logging\\Loggable::\$id\.#'
path: */app/Logging/LoggingHandler.php

- message: '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model::\$user_id\.#'
path: */app/Listeners/WebauthnRegistered.php

0 comments on commit 142de32

Please sign in to comment.