WebAuthn登录初步调通

This commit is contained in:
2022-08-08 10:31:45 +08:00
parent 6e4faf0865
commit f32c2e6344

@ -7,9 +7,9 @@ use App\WebAuthn\WebAuthnService;
use Cose\Algorithm\Manager; use Cose\Algorithm\Manager;
use Cose\Algorithm\Signature\ECDSA\ES256; use Cose\Algorithm\Signature\ECDSA\ES256;
use Cose\Algorithm\Signature\RSA\RS256; use Cose\Algorithm\Signature\RSA\RS256;
use Cose\Algorithms;
use GuzzleHttp\Psr7\ServerRequest; use GuzzleHttp\Psr7\ServerRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Webauthn\AttestationStatement\AttestationObjectLoader; use Webauthn\AttestationStatement\AttestationObjectLoader;
@ -115,10 +115,15 @@ class UserWebAuthnController extends BaseController
["localhost"] ["localhost"]
); );
} catch (\Throwable $e) { } catch (\Throwable $e) {
return redirect(route("login")); return new Response($e->getMessage(), 500);
} }
Auth::loginUsingId($publicKeyCredentialSource->getUserHandle()); Auth::loginUsingId($publicKeyCredentialSource->getUserHandle());
return redirect()->intended(); return [
"success" => true,
"code" => 0,
"message" => "登录成功",
"userId" => $publicKeyCredentialSource->getUserHandle()
];
} }
private function get_authn_attestation_response_validator(): AuthenticatorAttestationResponseValidator private function get_authn_attestation_response_validator(): AuthenticatorAttestationResponseValidator