Coder Social home page Coder Social logo

webauthn-server's Introduction

WebAuthn Relying Party server library for PHP

Scrutinizer Code Quality Code Coverage Build Status License: MIT

Current state

Pretty stable but the API may still change slightly until the 1.0 release.

Goal

This library aims to implement the relying party server of the WebAuthn specification in PHP. Important goals are:

  • Implement the level 1 WebAuthn specification
  • Good quality, secure and maintainable code
  • Easy to use for the end-user

Installation

Installation via composer:

composer require madwizard/webauthn

Supported features

  • PHP 7.2

  • FIDO conformant library
  • Attestation types:
    • FIDO U2F
    • Packed
    • TPM
    • Android SafetyNet
    • Android Key
    • Apple
    • None
    • Optional 'unsupported' type to handle future types
  • Metadata service support
  • Validating metadata
  • Extensions:
    • appid

Usage

The library is still in development so documentation is limited. The general pattern to follow is:

  1. Implement CredentialStoreInterface (you will need UserCredential or your own implementation of UserCredentialInterface)
  2. Create an instance of RelyingParty and use the ServerBuilder class to build a server object:
$server = (new ServerBuilder())
    ->setRelyingParty($rp)
    ->setCredentialStore($store)
    ->build();
  1. Use startRegistration/finishRegistration to register credentials. Be sure to store the temporary AttestationContext server side!
  2. and startAuthentication/finishAuthentication to authenticate. Be sure to store the temporary AssertionContext server side!

Resources

WebAuthn specification

webauthn-server's People

Contributors

madwizard-thomas avatar pevdh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

webauthn-server's Issues

7.2. Verifying an authentication assertion

Hi, I have been having a look at your project and it looks great.

I have also been trying to code the server side of webauthn and bumped into a problem with point '7.2. Verifying an authentication assertion' ( https://www.w3.org/TR/webauthn/#verifying-assertion ), and I think you might want to know about it.

Verification step 16 says: "Using the credential public key looked up in step 3, verify that sig is a valid signature over the binary concatenation of aData and hash." Doing just that I always got a signature that did not match with 'sig'. I spent a lot of hours checking my code without finding anything wrong. I inspected several source codes, including yours, and I found out that this repository, https://github.com/fido-alliance/webauthn-demo, did the verification differently. I tried it and it worked.
The correct concatenation that produces a valid signature is:
rpIdHash + flags (1 byte) + signature counter (4 bytes) + clientDataHash

I hope it helps. I suppose the W3C specification will be updated. By the way, I am using a 'FIDO2 Security Key' by Yubico.

Regards.

Feature Request: Make RegistrationOptions function chainable

Would it be possible to change the setter functions in the RegistrationOptions to return self instead of void? This would make it possible to be able to chain those and write something like this:

$opts = RegistrationOptions::createForUser($userIdentity)
            ->setExcludeExistingCredentials(true);
            ->setTimeout(20);
            ->setResidentKey(ResidentKeyRequirement::REQUIRED);
            ->setUserVerification(\MadWizard\WebAuthn\Dom\UserVerificationRequirement::REQUIRED);

instead of this

$opts = RegistrationOptions::createForUser($userIdentity);
$opts->setExcludeExistingCredentials(true);
$opts->setTimeout(20);
$opts->setResidentKey(ResidentKeyRequirement::REQUIRED);
$opts->setUserVerification(\MadWizard\WebAuthn\Dom\UserVerificationRequirement::REQUIRED);

kinda like the ServerBuilder works, this could be done without breaking existing code i think

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.