diff options
author | Joenio Costa <joenio@joenio.me> | 2019-07-21 12:30:44 -0300 |
---|---|---|
committer | Joenio Costa <joenio@joenio.me> | 2019-07-21 12:30:44 -0300 |
commit | 52993a6ec3d0a812d8bcdd7e9909ac2d7ea47116 (patch) | |
tree | 13e2f2fefe8ed236e51e8a1d4e99d01149e0254c | |
parent | 8f52cd795bbf6ea84b0dcb6c62e15b2f7ef67f32 (diff) | |
parent | 53ceb28a95cf80a80422bb3b425cdc6bf5701831 (diff) |
Update upstream source from tag 'upstream/4.02'
Update to upstream version '4.02'
with Debian dir 9f25478d3cc0851992ec6a1f1a92299f662c3929
-rw-r--r--[-rwxr-xr-x] | Changes | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | MANIFEST | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | Makefile.PL | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | README | 6 | ||||
-rw-r--r--[-rwxr-xr-x] | lib/Auth/Yubikey_WebClient.pm | 82 | ||||
-rw-r--r--[-rwxr-xr-x] | t/00-load.t | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | t/pod-coverage.t | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | t/pod.t | 0 |
8 files changed, 35 insertions, 53 deletions
diff --git a/Makefile.PL b/Makefile.PL index 4bd6222..4bd6222 100755..100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -30,8 +30,8 @@ perldoc command. You can also look for information at: - RT, CPAN's request tracker - http://rt.cpan.org/NoAuth/Bugs.html?Dist=Auth-Yubikey_WebClient + Issues + https://github.com/massyn/Auth-Yubikey_WebClient/issues AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Auth-Yubikey_WebClient @@ -45,7 +45,7 @@ You can also look for information at: COPYRIGHT AND LICENCE -Copyright (C) 2009 Phil Massyn +Copyright (C) 2019 Phil Massyn This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Auth/Yubikey_WebClient.pm b/lib/Auth/Yubikey_WebClient.pm index d6454c7..687b4e2 100755..100644 --- a/lib/Auth/Yubikey_WebClient.pm +++ b/lib/Auth/Yubikey_WebClient.pm @@ -13,11 +13,11 @@ Auth::Yubikey_WebClient - Authenticating the Yubikey against the Yubico Web API =head1 VERSION -Version 4.01 +Version 4.02 =cut -our $VERSION = '4.01'; +our $VERSION = '4.02'; =head1 SYNOPSIS @@ -88,36 +88,28 @@ sub new my $self = {}; bless $self, ref $class || $class; - - if(! defined $options_ref) - { + + if(! defined $options_ref) { die "You did not pass any parameters to the Yubikey Web Client initialization"; - } + } my %options = %{$options_ref}; # grab the variables from the initialization - if(defined $options{id}) - { + if(defined $options{id}) { $self->{id} = $options{id}; - } - else - { + } else { die "Can not start without a Yubikey ID"; } - if(defined $options{api}) - { - $self->{api} = $options{api}; + if(defined $options{api}) { + $self->{api} = $options{api}; - if(length($self->{api}) % 4 != 0) - { + if(length($self->{api}) % 4 != 0) { die "Your API key must be in 4 byte lengths"; } - } - else - { - die "Can not start without a Yubikey API key"; - } + } else { + die "Can not start without a Yubikey API key"; + } $self->{nonce} = defined $options{nonce} ? $options{nonce} : ''; @@ -154,10 +146,10 @@ sub debug print "sl = $self->{sl}\n"; print "timestamp = $self->{timestamp}\n"; print "sessioncounter = $self->{sessioncounter}\n"; - print "sessionuse = $self->{sessionuse}\n"; + print "sessionuse = $self->{sessionuse}\n"; # print "response = $self->{response}\n"; - + } =head2 yubikey_webclient @@ -193,13 +185,12 @@ sub otp $self->{otp} = $otp; # lets do a basic sanity check on the otp, before we blast it off to yubico... - if($self->{otp} !~ /[cbdefghijklnrtuv]/i || length($self->{otp}) < 32) - { + if($self->{otp} !~ /[cbdefghijklnrtuv]/i || length($self->{otp}) < 32) { $self->{status} = "ERR_BAD_OTP"; - return $self->{status}; + return $self->{status}; } - # Generate nonce unless passed + # Generate nonce unless passed $self->{nonce} = hmac_sha1_hex(time, rand()) unless $self->{nonce}; # Start generating the parameters @@ -208,20 +199,17 @@ sub otp # pass the request to yubico my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => $self->{verify_hostname} }); + $ua->env_proxy(); # 4.02 my $req = HTTP::Request->new(GET => $self->{url} . "?$self->{params}"); my $res = $ua->request($req); - if($res->is_success) - { + if($res->is_success) { $self->{response} = $res->content; - } - else - { + } else { print $res->status_line . "\n"; } chomp($self->{response}); - if($self->{response} !~ /status=ok/i) - { + if($self->{response} !~ /status=ok/i) { # If the status is not ok, let's not even go through the rest... $self->{response} =~ m/status=(.+)/; $self->{status} = "ERR_$1"; @@ -231,9 +219,8 @@ sub otp #extract each of the lines, and store in a hash... - my %result; - foreach (split(/\n/,$self->{response})) - { + my %result; + foreach (split(/\n/,$self->{response})) { chomp; if($_ =~ /=/) { @@ -251,8 +238,7 @@ sub otp my $datastring=''; my $key; - foreach $key (sort keys %result) - { + foreach $key (sort keys %result) { $result{$key} =~ s/\s//g; $datastring .= "$key=$result{$key}&"; } @@ -263,21 +249,16 @@ sub otp return "ERR_MSG_AUTH" unless ($self->{nonce} eq $result{nonce} and $self->{otp} eq $result{otp}); - my $hmac = encode_base64(hmac_sha1($datastring,decode_base64($self->{api}))); - - chomp($hmac); - - if($hmac eq $signatur) - { + my $hmac = encode_base64(hmac_sha1($datastring,decode_base64($self->{api}))); + chomp($hmac); + if($hmac eq $signatur) { $self->{publicid} = substr(lc($self->{otp}),0,12); $self->{status} = "OK"; return "OK"; - } - else - { + } else { $self->{status} = "ERR_HMAC"; - return "ERR_HMAC"; - } + return "ERR_HMAC"; + } } =head1 USAGE @@ -334,6 +315,7 @@ L<http://search.cpan.org/dist/Auth-Yubikey_WebClient> 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 =head1 ACKNOWLEDGEMENTS diff --git a/t/00-load.t b/t/00-load.t index 1676cc3..1676cc3 100755..100644 --- a/t/00-load.t +++ b/t/00-load.t diff --git a/t/pod-coverage.t b/t/pod-coverage.t index fc40a57..fc40a57 100755..100644 --- a/t/pod-coverage.t +++ b/t/pod-coverage.t |