1. Go to this page and download the library: Download surfnet/stepup-u2f-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
surfnet / stepup-u2f-bundle example snippets
public function registerBundles()
{
// ...
$bundles[] = new Surfnet\StepupU2fBundle\SurfnetStepupU2fBundle();
}
/** @Template */
public function registerDeviceAction(Request $request)
{
$service = $this->get('surfnet_stepup_u2f.service.u2f');
$registerRequest = $service->requestRegistration();
$registerResponse = new RegisterResponse();
$form = $this->createForm('surfnet_stepup_u2f_register_device', $registerResponse, [
'register_request' => $registerRequest,
]);
if (!$form->isValid()) {
$this->get('my.session.bag')->set('request', $registerRequest);
return ['form' => $form->createView()];
}
$result = $service->verifyRegistration(
$this->get('my.session.bag')->get('request'),
$registerResponse
);
if ($result->wasSuccessful()) {
$registration = $result->getRegistration());
// ...
} elseif ($result->handleAllErrorMethods()) {
// Display an error to the user and allow him/her to retry with a new request
}
}
/** @Template */
public function verifyDeviceAuthenticationAction(Request $request)
{
$service = $this->get('surfnet_stepup_u2f.service.authentication');
$signRequest = $service->requestAuthentication();
$signResponse = new SignResponse();
$form = $this->createForm('surfnet_stepup_u2f_verify_device_authentication', $signResponse, [
'sign_request' => $signRequest,
]);
if (!$form->isValid()) {
$this->get('my.session.bag')->set('request', $signRequest);
return ['form' => $form->createView()];
}
$result = $service->verifyAuthentication(
$this->get('my.session.bag')->get('request'),
$signResponse
);
if ($result->wasSuccessful()) {
// ...
} elseif ($result->handleAllErrorMethods()) {
// Display an error to the user and allow him/her to retry with a new request
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.