Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enygma/yubikey
PHP library to interface with the Yubikey REST API
https://github.com/enygma/yubikey
php security token yubikey
Last synced: 5 days ago
JSON representation
PHP library to interface with the Yubikey REST API
- Host: GitHub
- URL: https://github.com/enygma/yubikey
- Owner: enygma
- License: mit
- Created: 2013-03-01T20:18:02.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-06-05T14:16:00.000Z (7 months ago)
- Last Synced: 2024-10-30T08:18:14.279Z (2 months ago)
- Topics: php, security, token, yubikey
- Language: PHP
- Size: 72.3 KB
- Stars: 76
- Watchers: 7
- Forks: 16
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Yubikey PHP Library
=======================[![Travis-CI Build Status](https://secure.travis-ci.org/enygma/yubikey.png?branch=master)](http://travis-ci.org/enygma/yubikey)
[![Codacy Badge](https://www.codacy.com/project/badge/6b73c56a21734a6d93dae6019f733c5e)](https://www.codacy.com)
[![Code Climate](https://codeclimate.com/github/enygma/yubikey/badges/gpa.svg)](https://codeclimate.com/github/enygma/yubikey)
[![Total Downloads](https://img.shields.io/packagist/dt/enygma/yubikey.svg?style=flat-square)](https://packagist.org/packages/enygma/yubikey)This library lets you easily interface with the Yubico REST API for validating
the codes created by the Yubikey.### Requirements:
- An API as requested from the Yubico site
- A client ID requested from Yubico
- A Yubikey to test out the implementation### Installation
Use the followng command to install the library via Composer:
```
composer require enygma/yubikey
```### Usage:
Look at the `test.php` example script to see how to use it. This can be executed like:
`php test.php [generated key]`
Example code:
```php
check($inputtedKey);echo ($response->success() === true) ? 'success!' : 'you failed. aw.';
?>
```### HTTP vs HTTPS
By default the library will try to use a `HTTPS` request to the host given. If you need to disable this for some reason
(like no SSL support), you can use the `setUseSecure` method and set it to false:```php
$v = new \Yubikey\Validate($apiKey, $clientId);
$v->setUseSecure(false);
```### Overriding hosts
The library comes with a set of hostnames for the Yubico external API servers (api.yubico.com through api5.yubico.com). If
you ever have a need to override these, you can use `setHosts`:```php
$v = new \Yubikey\Validate($apiKey, $clientId);
$v->setHosts(array(
'api.myhost1.com',
'api1.myhost.com'
));
```
Remember, this will *overwrite* the current hosts in the class, so be sure you don't still need those. If you just want to add
another host, look at the `addHost` method.### Multi-Server Requests:
Additonally, the library also supports simultaneous connections to multiple servers. By default it will only make
the request to the first server in the `hosts` list. You can enable the multi-server checking with a second parameter on
the `check()` method:```php
check($inputtedKey, true);echo ($response->success() === true) ? 'success!' : 'you failed. aw.';
?>
````This will make multiple requests and return the pass/fail status of the aggregate responses from each. So, if you have all but one
server pass, the overall response will be a fail. If all return `OK` though, you're in the clear.### "First in" result
Additionally, you can also switch on and off this aggregation of the results and go with only the "first in" response. You do this
with a flag on the `success` checking method:```php
check($inputtedKey, true);echo ($response->success(true) === true) ? 'success!' : 'you failed. aw.';
?>
````**NOTE:** This will still work without multi-server checking. The "first in" will just always be the single response.
@author Chris Cornutt