Scroll to navigation

Auth::Yubikey_WebClient(3pm) User Contributed Perl Documentation Auth::Yubikey_WebClient(3pm)

NAME

Auth::Yubikey_WebClient - Authenticating the Yubikey against the Yubico Web API

VERSION

Version 4.02

SYNOPSIS

Authenticate against the Yubico server via the Web API in Perl

Sample CGI script :-

        #!/usr/bin/perl
        use CGI;
        use strict;
        my $cgi = new CGI;
        my $otp = $cgi->param("otp");
        print $cgi->header();
        print "<html>\n";
        print "<form method=get>Yubikey : <input type=text name=otp size=40 type=password></form>\n";
        use Auth::Yubikey_WebClient;
        my $id = "<enter your id here>";
        my $api = "<enter your API key here>";
        my $nonce = "<enter your nonce here>";
        if($otp)
        {
                my $result = Auth::Yubikey_WebClient::yubikey_webclient($otp,$id,$api,$nonce);
                # result can be either ERR or OK
                print "Authentication result : <b>$result</b><br>";
        }
        print "</html>\n";

FUNCTIONS

new

Creates a new Yubikey Webclient connection

   use Auth::Yubikey_WebClient;
   my $yubi = Auth::Yubikey_WebClient->new({
        id => <enter your id here> ,
        api => '<enter your API key here>' ,
        nonce => '<enter your nonce if you have one>',
        verify_hostname => 0    # optional - defaults to 1.  Can be set to 0 if you do not want to check the validity of the SSL certificate when querying the Yubikey server
        });

You can overwrite the URL called if you want to call an alternate authentication server as well :-

   use Auth::Yubikey_WebClient;
   my $yubi = Auth::Yubikey_WebClient->new({
        id => <enter your id here> ,
        api => '<enter your API key here>' ,
        nonce => '<enter your nonce if you have one>',
        url => 'http://www.otherserver.com/webapi.php'
        });

debug

Displays the debug info

   $yubi->debug();

Prints out some debug information. Useful to be called after authentication to see what Yubico sent back. You can also call the variables yourself, for example if you'd like to see what the token ID is, call $yubi->{publicid}. The same goes for all the other variables printed in debug.

yubikey_webclient

otp

Check a OTP for validity

        $result = $yubi->otp($otp);

Call the otp procedure with the input from the yubikey. It will return the result.

This function will also setup a few internal variables that was returned from Yubico.

USAGE

Before you can use this module, you need to register for an API key at Yubico. This is as simple as logging onto <https://upgrade.yubico.com/getapikey/> and entering your Yubikey's OTP and your email address. Once you have the API and ID, you need to provide those details to the module to work.

AUTHOR

Phil Massyn, "<massyn at gmail.com>"

BUGS

Please report any bugs or feature requests to "bug-auth-yubikey_webclient at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Auth-Yubikey_WebClient>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Auth::Yubikey_WebClient

You can also look for information at:

Version history

0.04 - Fixed bug <http://rt.cpan.org/Public/Bug/Display.html?id=51121> 1.00 - Added validation of the request to Yubico (Thanks to Kirill Miazine) 2.00 - Added nounce coding (Thanks to Ludvig af Klinteberg) 2.01 - Response turning into an array due to \r bug (Thanks to Peter Norin) 3.00 - Major update 4.01 - 13.10.2016 - Requested by Peter Norin - update to use LWP::UserAgent, and the option to overwrite a valid SSL certificate (verify_hostname). The API default server is changed to ssl. 4.02 - 2019.04.04 - Request by Alexandre Linte - Support for proxy servers

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2016 Phil Massyn, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2022-08-28 perl v5.34.0