madwizard/webauthn

PHP的Web Authentication API服务器

v0.10.0 2024-05-28 08:49 UTC

README

Scrutinizer Code Quality Code Coverage Build Status License: MIT

当前状态

非常稳定,但API在1.0版本发布前可能会有轻微的变化。

目标

这个库旨在用PHP实现WebAuthn规范的受信任方服务器。重要的目标包括

  • 实现第1级WebAuthn规范
  • 高质量的、安全的、可维护的代码
  • 易于最终用户使用

安装

通过composer安装

composer require madwizard/webauthn

支持的功能

  • PHP 7.2

  • FIDO兼容的库
  • 认证类型
    • FIDO U2F
    • 封装
    • TPM
    • Android SafetyNet
    • Android密钥
    • Apple
    • 可选的'不支持的'类型,以处理未来的类型
  • 元数据服务支持
  • 验证元数据
  • 扩展
    • appid

使用

该库仍在开发中,因此文档有限。遵循的一般模式是

  1. 实现CredentialStoreInterface(您需要UserCredential或您自己的UserCredentialInterface实现)
  2. 创建一个RelyingParty实例,并使用ServerBuilder类构建服务器对象
$server = (new ServerBuilder())
    ->setRelyingParty($rp)
    ->setCredentialStore($store)
    ->build();
  1. 使用startRegistration/finishRegistration来注册凭据。务必在服务器端存储临时的AttestationContext
  2. 以及使用startAuthentication/finishAuthentication进行身份验证。务必在服务器端存储临时的AssertionContext

资源

WebAuthn规范