Build Status | Scrutinizer Code Quality | |
---|---|---|
develop | ||
master |
A Symfony bundle to integrate Yubikey's OTP validation service.
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;
}
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.
}
}