Skip to content

Commit

Permalink
Move event dispatching from bundle to library (#312)
Browse files Browse the repository at this point in the history
Move event dispatching from bundle to library
  • Loading branch information
amenophis authored Oct 5, 2022
1 parent 4ed2ff5 commit 48f056a
Show file tree
Hide file tree
Showing 17 changed files with 500 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,41 @@
namespace Webauthn\Bundle\Event;

use Psr\Http\Message\ServerRequestInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Throwable;
use Webauthn\AuthenticatorAssertionResponse;
use Webauthn\Event\AuthenticatorAssertionResponseValidationFailedEvent as BaseAuthenticatorAssertionResponseValidationFailedEvent;
use Webauthn\PublicKeyCredentialRequestOptions;

/**
* @final
*/
class AuthenticatorAssertionResponseValidationFailedEvent extends Event
class AuthenticatorAssertionResponseValidationFailedEvent extends BaseAuthenticatorAssertionResponseValidationFailedEvent
{
public function __construct(
private readonly string $credentialId,
private readonly AuthenticatorAssertionResponse $authenticatorAssertionResponse,
private readonly PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions,
private readonly ServerRequestInterface $request,
private readonly ?string $userHandle,
private readonly Throwable $throwable
string $credentialId,
AuthenticatorAssertionResponse $authenticatorAssertionResponse,
PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions,
ServerRequestInterface $request,
?string $userHandle,
Throwable $throwable
) {
}

public function getCredentialId(): string
{
return $this->credentialId;
}

public function getAuthenticatorAssertionResponse(): AuthenticatorAssertionResponse
{
return $this->authenticatorAssertionResponse;
}

public function getPublicKeyCredentialRequestOptions(): PublicKeyCredentialRequestOptions
{
return $this->publicKeyCredentialRequestOptions;
}

public function getRequest(): ServerRequestInterface
{
return $this->request;
}

public function getUserHandle(): ?string
{
return $this->userHandle;
}

public function getThrowable(): Throwable
{
return $this->throwable;
trigger_deprecation(
'web-auth/webauthn-symfony-bundle',
'4.3.0',
sprintf(
'The class "%s" is deprecated since 4.3.0 and will be removed in 5.0.0. Please use "%s" instead.',
self::class,
BaseAuthenticatorAssertionResponseValidationFailedEvent::class
)
);

parent::__construct(
$credentialId,
$authenticatorAssertionResponse,
$publicKeyCredentialRequestOptions,
$request,
$userHandle,
$throwable
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,41 @@
namespace Webauthn\Bundle\Event;

use Psr\Http\Message\ServerRequestInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Webauthn\AuthenticatorAssertionResponse;
use Webauthn\Event\AuthenticatorAssertionResponseValidationSucceededEvent as BaseAuthenticatorAssertionResponseValidationSucceededEvent;
use Webauthn\PublicKeyCredentialRequestOptions;
use Webauthn\PublicKeyCredentialSource;

/**
* @final
*/
class AuthenticatorAssertionResponseValidationSucceededEvent extends Event
class AuthenticatorAssertionResponseValidationSucceededEvent extends BaseAuthenticatorAssertionResponseValidationSucceededEvent
{
public function __construct(
private readonly string $credentialId,
private readonly AuthenticatorAssertionResponse $authenticatorAssertionResponse,
private readonly PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions,
private readonly ServerRequestInterface $request,
private readonly ?string $userHandle,
private readonly PublicKeyCredentialSource $publicKeyCredentialSource
string $credentialId,
AuthenticatorAssertionResponse $authenticatorAssertionResponse,
PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions,
ServerRequestInterface $request,
?string $userHandle,
PublicKeyCredentialSource $publicKeyCredentialSource
) {
}

public function getCredentialId(): string
{
return $this->credentialId;
}

public function getAuthenticatorAssertionResponse(): AuthenticatorAssertionResponse
{
return $this->authenticatorAssertionResponse;
}

public function getPublicKeyCredentialRequestOptions(): PublicKeyCredentialRequestOptions
{
return $this->publicKeyCredentialRequestOptions;
}

public function getRequest(): ServerRequestInterface
{
return $this->request;
}

public function getUserHandle(): ?string
{
return $this->userHandle;
}

public function getPublicKeyCredentialSource(): PublicKeyCredentialSource
{
return $this->publicKeyCredentialSource;
trigger_deprecation(
'web-auth/webauthn-symfony-bundle',
'4.3.0',
sprintf(
'The class "%s" is deprecated since 4.3.0 and will be removed in 5.0.0. Please use "%s" instead.',
self::class,
BaseAuthenticatorAssertionResponseValidationSucceededEvent::class
)
);

parent::__construct(
$credentialId,
$authenticatorAssertionResponse,
$publicKeyCredentialRequestOptions,
$request,
$userHandle,
$publicKeyCredentialSource
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,37 @@
namespace Webauthn\Bundle\Event;

use Psr\Http\Message\ServerRequestInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Throwable;
use Webauthn\AuthenticatorAttestationResponse;
use Webauthn\Event\AuthenticatorAttestationResponseValidationFailedEvent as BaseAuthenticatorAttestationResponseValidationFailedEvent;
use Webauthn\PublicKeyCredentialCreationOptions;

/**
* @final
*/
class AuthenticatorAttestationResponseValidationFailedEvent extends Event
class AuthenticatorAttestationResponseValidationFailedEvent extends BaseAuthenticatorAttestationResponseValidationFailedEvent
{
public function __construct(
private readonly AuthenticatorAttestationResponse $authenticatorAttestationResponse,
private readonly PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
private readonly ServerRequestInterface $request,
private readonly Throwable $throwable
AuthenticatorAttestationResponse $authenticatorAttestationResponse,
PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
ServerRequestInterface $request,
Throwable $throwable
) {
}

public function getAuthenticatorAttestationResponse(): AuthenticatorAttestationResponse
{
return $this->authenticatorAttestationResponse;
}

public function getPublicKeyCredentialCreationOptions(): PublicKeyCredentialCreationOptions
{
return $this->publicKeyCredentialCreationOptions;
}

public function getRequest(): ServerRequestInterface
{
return $this->request;
}

public function getThrowable(): Throwable
{
return $this->throwable;
trigger_deprecation(
'web-auth/webauthn-symfony-bundle',
'4.3.0',
sprintf(
'The class "%s" is deprecated since 4.3.0 and will be removed in 5.0.0. Please use "%s" instead.',
self::class,
BaseAuthenticatorAttestationResponseValidationFailedEvent::class
)
);

parent::__construct(
$authenticatorAttestationResponse,
$publicKeyCredentialCreationOptions,
$request,
$throwable
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,37 @@
namespace Webauthn\Bundle\Event;

use Psr\Http\Message\ServerRequestInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Webauthn\AuthenticatorAttestationResponse;
use Webauthn\Event\AuthenticatorAttestationResponseValidationSucceededEvent as BaseAuthenticatorAttestationResponseValidationSucceededEvent;
use Webauthn\PublicKeyCredentialCreationOptions;
use Webauthn\PublicKeyCredentialSource;

/**
* @final
*/
class AuthenticatorAttestationResponseValidationSucceededEvent extends Event
class AuthenticatorAttestationResponseValidationSucceededEvent extends BaseAuthenticatorAttestationResponseValidationSucceededEvent
{
public function __construct(
private readonly AuthenticatorAttestationResponse $authenticatorAttestationResponse,
private readonly PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
private readonly ServerRequestInterface $request,
private readonly PublicKeyCredentialSource $publicKeyCredentialSource
AuthenticatorAttestationResponse $authenticatorAttestationResponse,
PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
ServerRequestInterface $request,
PublicKeyCredentialSource $publicKeyCredentialSource
) {
}

public function getAuthenticatorAttestationResponse(): AuthenticatorAttestationResponse
{
return $this->authenticatorAttestationResponse;
}

public function getPublicKeyCredentialCreationOptions(): PublicKeyCredentialCreationOptions
{
return $this->publicKeyCredentialCreationOptions;
}

public function getRequest(): ServerRequestInterface
{
return $this->request;
}

public function getPublicKeyCredentialSource(): PublicKeyCredentialSource
{
return $this->publicKeyCredentialSource;
trigger_deprecation(
'web-auth/webauthn-symfony-bundle',
'4.3.0',
sprintf(
'The class "%s" is deprecated since 4.3.0 and will be removed in 5.0.0. Please use "%s" instead.',
self::class,
BaseAuthenticatorAttestationResponseValidationSucceededEvent::class
)
);

parent::__construct(
$authenticatorAttestationResponse,
$publicKeyCredentialCreationOptions,
$request,
$publicKeyCredentialSource
);
}
}
2 changes: 1 addition & 1 deletion src/symfony/src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
Expand All @@ -14,7 +15,6 @@
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Webauthn\AttestationStatement\AttestationObjectLoader;
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
use Webauthn\AttestationStatement\NoneAttestationStatementSupport;
Expand Down
Loading

0 comments on commit 48f056a

Please sign in to comment.