sebastiancx / webauthn

PHP的Web Authentication API服务器

v0.0.1 2023-06-24 09:54 UTC

This package is auto-updated.

Last update: 2024-09-24 12:32:20 UTC


README

Scrutinizer Code Quality Code Coverage Build Status License: MIT

当前状态

相对稳定,但API在1.0版本发布前可能还会略有变动。

目标

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

  • 实现WebAuthn 1级规范
  • 高质量的、安全的、可维护的代码
  • 对最终用户友好

安装

通过composer安装

composer require sebastiancx/webauthn

支持的功能

  • PHP 8.1

  • FIDO兼容的库
  • 认证类型
    • FIDO U2F
    • 打包
    • TPM
    • Android SafetyNet
    • Android Key
    • 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规范