surfnet/yubikey-api-client-bundle

A Symfony2 bundle to integrate Yubikey OTP validation service.

4.0.0 2020-11-25 10:17 UTC

This package is auto-updated.

Last update: 2021-03-25 11:03:17 UTC


README

Build Status Scrutinizer Code Quality
develop Build Status Scrutinizer Code Quality
master Build Status Scrutinizer Code Quality

A Symfony2 & 3 bundle to integrate Yubikey's OTP validation service.

Installation

Add the bundle to your Composer file.

composer require 'surfnet/yubikey-api-client-bundle'

Add the bundle to your AppKernel.

public function registerBundles()
{
    $bundles[] = new Surfnet\YubikeyApiClientBundle\SurfnetYubikeyApiClientBundle;
}

Usage

public function fooAction()
{
    /** @var \Surfnet\YubikeyApiClientBundle\Service\VerificationService */
    $service = $this->get('surfnet_yubikey_api_client.verification_service');
    
    if (!\Surfnet\YubikeyApiClient\Otp::isValid('user-input-otp-here')) {
        // User-entered OTP string is not valid.
    }
    
    $otp = \Surfnet\YubikeyApiClient\Otp::fromString('user-input-otp-here');
    $result = $service->verify($otp);
    
    if ($result->isSuccessful()) {
        // Yubico verified OTP.
    }
}