First release
This commit is contained in:
45
src/Assertion/Creator/Pipes/CreateAssertionChallenge.php
Normal file
45
src/Assertion/Creator/Pipes/CreateAssertionChallenge.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Laragear\WebAuthn\Assertion\Creator\Pipes;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Laragear\WebAuthn\Assertion\Creator\AssertionCreation;
|
||||
use Laragear\WebAuthn\Attestation\SessionChallenge;
|
||||
|
||||
class CreateAssertionChallenge
|
||||
{
|
||||
use SessionChallenge;
|
||||
|
||||
/**
|
||||
* Create a new pipe instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*/
|
||||
public function __construct(protected Repository $config)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the incoming Assertion.
|
||||
*
|
||||
* @param \Laragear\WebAuthn\Assertion\Creator\AssertionCreation $assertion
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(AssertionCreation $assertion, Closure $next): mixed
|
||||
{
|
||||
$options = [];
|
||||
|
||||
if ($assertion->acceptedCredentials?->isNotEmpty()) {
|
||||
$options['credentials'] = $assertion->acceptedCredentials->map->getKey()->toArray();
|
||||
}
|
||||
|
||||
$challenge = $this->storeChallenge($assertion->request, $assertion->userVerification, $options);
|
||||
|
||||
$assertion->json->set('challenge', $challenge->data);
|
||||
|
||||
return $next($assertion);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user