The Symfony Way

Lucky Symfony applications!

An official bundle is provided in the package web-auth/webauthn-symfony-bundle.

If you use Laravel, you may be interested in this project: https://github.com/asbiin/laravel-webauthn

Before installing it, please make sure you installed and configured:

composer require symfony/psr-http-message-bridge nyholm/psr7 annotations
config/packages/sensio:framework:extra.yaml
sensio_framework_extra:
    psr_message:
        enabled: true

If you are using Symfony Flex then the bundle will automatically be installed and the default configuration will be set. Otherwise you need to add it in your AppKernel.php file:

src/AppKernel.php
<?php

public function registerBundles()
{
    $bundles = [
        // ...
        new Webauthn\Bundle\WebauthnBundle(),
    ];
}

And add the Webauthn Route Loader:

Repositories

The first step is to create your credential and user entity repositories.

Only Doctrine ORM based repositories are provided. Other storage systems like filesystem or Doctrine ODM may be added in the future but, at the moment, you have to create these from scratch.

Configuration

With Flex, you have a minimal configuration file installed through a Flex Recipe. You must set the repositories you have just created. You also have to modify the environment variables Relying_PARTY_ID and Relying_PARTY_NAME.

You may also need to adjust other parameters.

If you don’t use Flex, hereafter an example of configuration file:

Repositories

The credential_repository and user_repository parameters correspond to the services we created above.

Token Binding Handler

Please refer to this page. You should let the default value as it is.

Creation Profiles

Relying Party (rp)

The realying Party corresponds to your application. Please refer to this page for more information.

Challenge Length

By default, the length of the challenge is 32 bytes. You may need to select a smaller or higher length. This length can be configured for each profile:

Timeout

The default timeout is set to 60 seconds (60 000 milliseconds). You can change this value as follows:

For v4.0+, the timeout will be set to null. The values recommended by the specification are as follow:

  • If the user verification is discouraged, timeout should be between 30 and 180 seconds

  • If the user verification is preferred or required, the range is 300 to 600 seconds (5 to 10 minutes)

Authenticator Selection Criteria

This set of options allows you to select authenticators depending on their capabilities. The values are described in the advanced concepts of the protocol.

Public Key Credential Parameters

This option indicates the algorithms allowed for your application. By default, a large list of algorithms is defined, but you can add custom algorithms or reduce the list.

The order is important. Preferred algorithms go first.

Attestation Conveyance

If you need the attestation of the authenticator, you can specify the preference regarding attestation conveyance during credential generation.

Extensions

You can set as many extensions as you want in the profile. Please also refer to this page for more information.

The example below is totally fictive. Some extensions are defined in the specification but the support depends on the authenticators, on the browsers and on the relying parties (your applications).

Request Profiles

The parameters for the request profiles (i.e. the authentication) are very similar to the creation profiles. The only difference is that you don’t need all the detail of the Relying Party, but only its ID (i.e. its domain).

Please note that all parameters are optional. The following configuration is perfectly valid. However, and as mentioned above, the parameter id is highly recommended.

Firewall

Now you have a fully configured bundle, you can protect your routes and manage the user registration and authenticatin through the Symfony Firewall.

Last updated

Was this helpful?