Mojolicious::Plugin::YubiVerify - Verify YubiKey one time passwords.
Mojolicous::Plugin::YubiVerify verifies YubiKey one time passwords. The library implements YubiKey Validation Protocol version 2.0 as described here:
http://code.google.com/p/yubikey-val-server-php/wiki/ValidationProtocolV20
This library will query following servers: api.yubico.com, api2.yubico.com, api3.yubico.com, api4.yubico.com and api5.yubico.com. User may wish to use all - or only some - of the servers. If number of servers to query is lower than 5, then the server(s) to query will be selected randomly.
Yubico API key and API id are required and must be obtained prior to using this module. http://api.yubico.com/get-api-key/
yubi_verify(<otp>) helper function takes one time password as its argument and returns the id associated with the one time password if authentication was successful.
Below is a usage example togehter with basic_auth. Note that if using one time passwords with basic auth, you have to set some session parameter if initial authentication was successful. Don't forget to expire it!
use Mojolicious::Lite; app->plugin('basic_auth'); app->plugin('yubi_verify', api_id => '...', # API id api_key => '...', # API key parallel => 3, # number of servers to query ); get '/' => sub { my $self = shift; return $self->render_text("yubikey id is @{[$self->session->{'yubi'}]}") if $self->basic_auth( realm => sub { return 1 if $self->session->{'yubi'}; return 1 if $self->session->{'yubi'} = $self->yubi_verify($_[1]) } ); }; app->start;
Mojolicious::Plugin::YubiVerify inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register;
Register condition in Mojolicious application. Please see USAGE above for arguments.
Mojolicious
0.01
Kirill Miazine km@krot.orgrg
To install Mojolicious::Plugin::YubiVerify, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::YubiVerify
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::YubiVerify
For more information on module installation, please visit the detailed CPAN module installation guide.