faiare/laravel-webauthn 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

faiare/laravel-webauthn

最新稳定版本:0.1.0

Composer 安装命令:

composer require faiare/laravel-webauthn

包简介

A WebAuthn library for Laravel

README 文档

README

This project is currently under development.

It references the following repository extensively: https://github.com/davidearl/webauthn

For a comprehensive solution, consider using the well-established adapter available at: https://github.com/asbiin/laravel-webauthn

This adapter offers a seamless integration of both front-end and back-end components.

In contrast, this library provides only a simple authentication Facade.

Included Features

  • Back-end Registration [x]
  • Back-end Authentication [x]
  • Front-end Registration []
  • Front-end Authentication []
  • Store WebAuthn keys in database []

Requirements

  • PHP 8.2 or higher
  • Laravel 10.0 or higher
  • ext-openssl

Installation

composer require faiare/laravel-webauthn

Usage

Register Passkey

use Faiare\LaravelWebAuthn\Facades\WebAuthn;

$publicKey = WebAuthn::prepareChallengeForRegistration(
    username: 'username',
    userid: '100',
    crossPlatform: true,
);

Frontend example is in the examples directory.

use Faiare\LaravelWebAuthn\Facades\WebAuthn;
use Illuminate\Support\Facades\DB;

// info must be a string
$info = request()->input('credential');

$publicKey = WebAuthn::register($info);

// store the public key, example...
DB::table('web_authn_keys')->insert([
    'webauthn_id' => $publicKey->webauthnId,
    'webauthn_key' => $publicKey->webauthnKey,
]);

Authenticate Passkey

use Faiare\LaravelWebAuthn\Facades\WebAuthn;

$publicKey = WebAuthn::prepareForAuthenticate();

Frontend example is in the examples directory.

use Faiare\LaravelWebAuthn\Facades\WebAuthn;
use \Illuminate\Support\Facades\DB;

// info must be a string
$info = request()->input('credential');
$webAuthnId = WebAuthn::parseWebAuthnId($info);

// table must have a column named webauthn_id, webauthn_key
$webAuthnKey = DB::table('web_authn_keys')->where('webauthn_id', $webAuthnId)->first();

$success = WebAuthn::authenticate($info, $webAuthnKey);

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-22