Skip to content

Commit 5cdfdc3

Browse files
committed
update
1 parent 20c81ef commit 5cdfdc3

File tree

3 files changed

+24
-46
lines changed

3 files changed

+24
-46
lines changed

src/Events/EventDispatcher.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function __construct(
1919
*
2020
* @return object
2121
*/
22+
#[\Override]
2223
public function dispatch(object $event)
2324
{
2425
$this->dispatcher->dispatch($event);

src/Http/Controllers/ConfirmableKeyController.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,11 @@
1313

1414
class ConfirmableKeyController extends Controller
1515
{
16-
/**
17-
* The guard implementation.
18-
*
19-
* @var \Illuminate\Contracts\Auth\StatefulGuard
20-
*/
21-
protected $guard;
22-
2316
/**
2417
* Create a new controller instance.
2518
*/
26-
public function __construct(StatefulGuard $guard)
27-
{
28-
$this->guard = $guard;
29-
}
19+
public function __construct(
20+
protected StatefulGuard $guard) {}
3021

3122
/**
3223
* Confirm the user's key.

src/WebauthnServiceProvider.php

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use LaravelWebauthn\Http\Responses\RegisterViewResponse;
3636
use LaravelWebauthn\Http\Responses\UpdateResponse;
3737
use LaravelWebauthn\Services\Webauthn;
38+
use Psr\EventDispatcher\EventDispatcherInterface;
3839
use Psr\Http\Client\ClientInterface;
3940
use Psr\Http\Message\RequestFactoryInterface;
4041
use Psr\Http\Message\ResponseFactoryInterface;
@@ -46,7 +47,6 @@
4647
use Symfony\Component\Serializer\SerializerInterface;
4748
use Webauthn\AttestationStatement\AndroidKeyAttestationStatementSupport;
4849
use Webauthn\AttestationStatement\AppleAttestationStatementSupport;
49-
use Webauthn\AttestationStatement\AttestationObjectLoader;
5050
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
5151
use Webauthn\AttestationStatement\FidoU2FAttestationStatementSupport;
5252
use Webauthn\AttestationStatement\NoneAttestationStatementSupport;
@@ -68,6 +68,24 @@
6868
*/
6969
class WebauthnServiceProvider extends ServiceProvider
7070
{
71+
/**
72+
* All of the container singletons that should be registered.
73+
*
74+
* @var array
75+
*/
76+
public $singletons = [
77+
WebauthnFacade::class => Webauthn::class,
78+
DestroyResponseContract::class => DestroyResponse::class,
79+
LoginSuccessResponseContract::class => LoginSuccessResponse::class,
80+
LoginViewResponseContract::class => LoginViewResponse::class,
81+
RegisterSuccessResponseContract::class => RegisterSuccessResponse::class,
82+
RegisterViewResponseContract::class => RegisterViewResponse::class,
83+
UpdateResponseContract::class => UpdateResponse::class,
84+
KeyConfirmedResponseContract::class => KeyConfirmedResponse::class,
85+
FailedKeyConfirmedResponseContract::class => FailedKeyConfirmedResponse::class,
86+
EventDispatcherInterface::class => EventDispatcher::class,
87+
];
88+
7189
/**
7290
* Bootstrap any application services.
7391
*/
@@ -85,18 +103,14 @@ public function boot(): void
85103
#[\Override]
86104
public function register(): void
87105
{
88-
$this->app->bind('webauthn.log', fn ($app) => $app['log']->channel(config('webauthn.log', config('logging.default'))));
89-
90-
$this->app->singleton(WebauthnFacade::class, Webauthn::class);
91-
92-
$this->registerResponseBindings();
93106
$this->bindWebAuthnPackage();
94107
$this->bindPsrInterfaces();
95108

96109
$this->mergeConfigFrom(
97110
__DIR__.'/../config/webauthn.php', 'webauthn'
98111
);
99112

113+
$this->app->bind('webauthn.log', fn ($app) => $app['log']->channel(config('webauthn.log', config('logging.default'))));
100114
$this->app->bind(StatefulGuard::class, fn () => Auth::guard(config('webauthn.guard', null)));
101115
}
102116

@@ -116,36 +130,14 @@ private function configureRoutes(): void
116130
}
117131
}
118132

119-
/**
120-
* Register the response bindings.
121-
*/
122-
public function registerResponseBindings(): void
123-
{
124-
$this->app->singleton(DestroyResponseContract::class, DestroyResponse::class);
125-
$this->app->singleton(LoginSuccessResponseContract::class, LoginSuccessResponse::class);
126-
$this->app->singleton(LoginViewResponseContract::class, LoginViewResponse::class);
127-
$this->app->singleton(RegisterSuccessResponseContract::class, RegisterSuccessResponse::class);
128-
$this->app->singleton(RegisterViewResponseContract::class, RegisterViewResponse::class);
129-
$this->app->singleton(UpdateResponseContract::class, UpdateResponse::class);
130-
$this->app->singleton(KeyConfirmedResponseContract::class, KeyConfirmedResponse::class);
131-
$this->app->singleton(FailedKeyConfirmedResponseContract::class, FailedKeyConfirmedResponse::class);
132-
}
133-
134133
/**
135134
* Bind all the WebAuthn package services to the Service Container.
136135
*/
137136
protected function bindWebAuthnPackage(): void
138137
{
139-
$this->app->singleton(EventDispatcher::class);
140-
$this->app->resolving(CanDispatchEvents::class, fn (CanDispatchEvents $object) => $object->setEventDispatcher($this->app[EventDispatcher::class]));
138+
$this->app->resolving(CanDispatchEvents::class, fn (CanDispatchEvents $object) => $object->setEventDispatcher($this->app[EventDispatcherInterface::class]));
141139
$this->app->resolving(CanLogData::class, fn (CanLogData $object) => $object->setLogger($this->app['webauthn.log']));
142140

143-
$this->app->bind(
144-
PackedAttestationStatementSupport::class,
145-
fn ($app) => new PackedAttestationStatementSupport(
146-
algorithmManager: $app[CoseAlgorithmManager::class]
147-
)
148-
);
149141
$this->app->bind(
150142
AttestationStatementSupportManager::class,
151143
fn ($app) => tap(new AttestationStatementSupportManager, function ($manager) use ($app) {
@@ -168,12 +160,6 @@ protected function bindWebAuthnPackage(): void
168160
}
169161
})
170162
);
171-
$this->app->bind(
172-
AttestationObjectLoader::class,
173-
fn ($app) => new AttestationObjectLoader(
174-
attestationStatementSupportManager: $app[AttestationStatementSupportManager::class]
175-
)
176-
);
177163
$this->app->bind(
178164
SerializerInterface::class,
179165
fn ($app) => (new \Webauthn\Denormalizer\WebauthnSerializerFactory($app[AttestationStatementSupportManager::class]))->create()

0 commit comments

Comments
 (0)