r54149 - in /branches/upstream/libnet-oauth-perl/current: ./ demos/echo-provider/ lib/Net/ lib/Net/OAuth/ t/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Fri Mar 12 00:03:19 UTC 2010


Author: jawnsy-guest
Date: Fri Mar 12 00:02:58 2010
New Revision: 54149

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=54149
Log:
[svn-upgrade] Integrating new upstream version, libnet-oauth-perl (0.22)

Added:
    branches/upstream/libnet-oauth-perl/current/demos/echo-provider/
    branches/upstream/libnet-oauth-perl/current/demos/echo-provider/.htaccess
    branches/upstream/libnet-oauth-perl/current/demos/echo-provider/request-token.cgi   (with props)
    branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/XauthAccessTokenRequest.pm
    branches/upstream/libnet-oauth-perl/current/t/12-xauth.t
Modified:
    branches/upstream/libnet-oauth-perl/current/Changes
    branches/upstream/libnet-oauth-perl/current/MANIFEST
    branches/upstream/libnet-oauth-perl/current/META.yml
    branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth.pm
    branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Message.pm
    branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Request.pm

Modified: branches/upstream/libnet-oauth-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/Changes?rev=54149&op=diff
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/Changes (original)
+++ branches/upstream/libnet-oauth-perl/current/Changes Fri Mar 12 00:02:58 2010
@@ -75,6 +75,12 @@
   Fixed http://rt.cpan.org/Public/Bug/Display.html?id=48867 - error in synopsis - thanks Adam Taylor!
   Removed UTF8 double-encoding warning.  Now Net::OAuth::Message::encode() uses Encode::is_utf8() to determine if the input is already UTF-8 encoded.  If so, it runs decode_utf8() on it before sending it to uri_escape_utf8().  Thanks Hector Garcia Alvarez!
   Potentially fixed an issue found by Marc Mims, where HMAC_SHA1 was failing to load, breaking some CPAN tests.  Build.PL now explicitly requires Digest::SHA1 and Encode.  Hopefully that fixes it.
-  
-        
+
+0.21   Wed, 10 Mar 2010 22:20:49 UTC
+  Added xAuth support with xAuthAccessTokenRequest (thanks Masayoshi Sekimura and Simon Wistow)
+  Added performance patch to decrease stat() system calls when requiring modules (thanks Brad Whitaker)
+
+0.22   Thu, 11 Mar 2010 00:21:26 UTC
+  Renamed xAuthAccessTokenRequest to XauthAccessTokenRequest for CamelCaseConsistency
+  Added a couple tests for XauthAccessTokenRequest
     

Modified: branches/upstream/libnet-oauth-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/MANIFEST?rev=54149&op=diff
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/MANIFEST (original)
+++ branches/upstream/libnet-oauth-perl/current/MANIFEST Fri Mar 12 00:02:58 2010
@@ -1,5 +1,7 @@
 Build.PL
 Changes
+demos/echo-provider/.htaccess
+demos/echo-provider/request-token.cgi
 demos/google/.htaccess
 demos/google/config.yml
 demos/google/default.html
@@ -37,6 +39,7 @@
 lib/Net/OAuth/V1_0A/RequestTokenRequest.pm
 lib/Net/OAuth/V1_0A/RequestTokenResponse.pm
 lib/Net/OAuth/V1_0A/UserAuthResponse.pm
+lib/Net/OAuth/XauthAccessTokenRequest.pm
 Makefile.PL
 MANIFEST			This list of files
 META.yml
@@ -51,5 +54,6 @@
 t/09-encoding.t
 t/10-misc.t
 t/11-spec-1.0a.t
+t/12-xauth.t
 t/rsakey
 t/rsakey.pub

Modified: branches/upstream/libnet-oauth-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/META.yml?rev=54149&op=diff
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/META.yml (original)
+++ branches/upstream/libnet-oauth-perl/current/META.yml Fri Mar 12 00:02:58 2010
@@ -1,6 +1,6 @@
 ---
 name: Net-OAuth
-version: 0.20
+version: 0.22
 author:
   - 'Keith Grennan <kgrennan at cpan.org>'
 abstract: An implementation of the OAuth protocol
@@ -21,7 +21,7 @@
 provides:
   Net::OAuth:
     file: lib/Net/OAuth.pm
-    version: 0.20
+    version: 0.22
   Net::OAuth::AccessTokenRequest:
     file: lib/Net/OAuth/AccessTokenRequest.pm
   Net::OAuth::AccessTokenResponse:
@@ -34,7 +34,7 @@
     file: lib/Net/OAuth/ProtectedResourceRequest.pm
   Net::OAuth::Request:
     file: lib/Net/OAuth/Request.pm
-    version: 0.20
+    version: 0.22
   Net::OAuth::RequestTokenRequest:
     file: lib/Net/OAuth/RequestTokenRequest.pm
   Net::OAuth::RequestTokenResponse:
@@ -59,6 +59,8 @@
     file: lib/Net/OAuth/V1_0A/RequestTokenResponse.pm
   Net::OAuth::V1_0A::UserAuthResponse:
     file: lib/Net/OAuth/V1_0A/UserAuthResponse.pm
+  Net::OAuth::XauthAccessTokenRequest:
+    file: lib/Net/OAuth/XauthAccessTokenRequest.pm
 generated_by: Module::Build version 0.35
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html

Added: branches/upstream/libnet-oauth-perl/current/demos/echo-provider/.htaccess
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/demos/echo-provider/.htaccess?rev=54149&op=file
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/demos/echo-provider/.htaccess (added)
+++ branches/upstream/libnet-oauth-perl/current/demos/echo-provider/.htaccess Fri Mar 12 00:02:58 2010
@@ -1,0 +1,2 @@
+AddHandler cgi-script .cgi
+Options +FollowSymLinks +ExecCGI

Added: branches/upstream/libnet-oauth-perl/current/demos/echo-provider/request-token.cgi
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/demos/echo-provider/request-token.cgi?rev=54149&op=file
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/demos/echo-provider/request-token.cgi (added)
+++ branches/upstream/libnet-oauth-perl/current/demos/echo-provider/request-token.cgi Fri Mar 12 00:02:58 2010
@@ -1,0 +1,52 @@
+#!/opt/local/bin/perl
+
+use strict;
+use warnings;
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
+use lib qw(../../lib);
+use Net::OAuth;
+use URI;
+
+my $q = new CGI;
+
+use Data::Dumper;
+$Data::Dumper::Terse=1;
+$Data::Dumper::Useqq=1;
+
+my $request = eval {Net::OAuth->request("request token")->from_hash({$q->Vars},
+    request_url => $q->url,
+    request_method => $q->request_method,
+    consumer_secret => 'secret',
+)};
+
+if ($@) {
+    print $q->header(-status => '400 Invalid Request', -type => 'text/plain');
+    print "Invalid request: $@\n";
+    print "Vars", Dumper({$q->Vars});
+    print "Query", Dumper({URI->new($q->url(-query=>1))->query_form});
+    print "Env: ", Dumper(\%ENV), "\n";
+    exit;
+}
+
+print STDERR $request->signature_base_string;
+
+if (!$request->verify) {
+    print $q->header(-status => '400 Signature verification failed', -type => 'text/plain');
+    print "Signature verification failed.\n";
+    print "Base string: ", $request->signature_base_string, "\n";
+    print "Vars", Dumper({$q->Vars});
+    print "Env: ", Dumper(\%ENV), "\n";
+    exit;
+}
+else {
+    # Service Provider sends Request Token Response
+
+    my $response = Net::OAuth->response("request token")->new( 
+        token => 'request-token',
+        token_secret => 'request-secret',
+    );
+    
+    print $q->header('text/plain');
+    print $response->to_post_body;
+}    

Propchange: branches/upstream/libnet-oauth-perl/current/demos/echo-provider/request-token.cgi
------------------------------------------------------------------------------
    svn:executable = *

Modified: branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth.pm?rev=54149&op=diff
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth.pm (original)
+++ branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth.pm Fri Mar 12 00:02:58 2010
@@ -8,7 +8,7 @@
 
 sub OAUTH_VERSION() {'1.0'}
 
-our $VERSION = '0.20';
+our $VERSION = '0.22';
 our $SKIP_UTF8_DOUBLE_ENCODE_CHECK = 0; # this is not actually used any more
 our $PROTOCOL_VERSION = PROTOCOL_VERSION_1_0;
 
@@ -29,7 +29,7 @@
     my $base_class = ref $self || $self;
     my $type = camel(shift);
     my $class = $base_class . '::' . $type;
-    $class->require;
+    smart_require($class);
     return $class;
 }
 
@@ -42,6 +42,16 @@
         }
     }
     my $name = join('', map("\u$_", @words));
+}
+
+our %ALREADY_REQUIRED = (); # class_name => rv of ->require
+
+sub smart_require {
+    my $required_class = shift;
+    unless (exists $ALREADY_REQUIRED{$required_class}) {
+        $ALREADY_REQUIRED{$required_class} = $required_class->require;
+    }
+    return $ALREADY_REQUIRED{$required_class};
 }
 
 =head1 NAME

Modified: branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Message.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Message.pm?rev=54149&op=diff
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Message.pm (original)
+++ branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Message.pm Fri Mar 12 00:02:58 2010
@@ -3,7 +3,6 @@
 use strict;
 use base qw/Class::Data::Inheritable Class::Accessor/;
 use URI::Escape;
-use UNIVERSAL::require;
 use Net::OAuth;
 use URI;
 use URI::QueryParam;
@@ -65,9 +64,7 @@
     my $protocol_version = $params->{protocol_version} || $Net::OAuth::PROTOCOL_VERSION;
     if (defined $protocol_version and $protocol_version == Net::OAuth::PROTOCOL_VERSION_1_0A and $class !~ /\::V1_0A\::/) {
         (my $versioned_class = $class) =~ s/::(\w+)$/::V1_0A::$1/;
-        if ($versioned_class->require) {
-            return $versioned_class;
-        }
+        return $versioned_class if Net::OAuth::smart_require($versioned_class);
     }
     return $class;
 }
@@ -104,7 +101,7 @@
     my $str = shift;
     $str = "" unless defined $str;
     if ($str =~ /[\x80-\xFF]/) {
-        Encode->require;
+        Net::OAuth::smart_require('Encode');
         no strict 'subs';
         if (Encode::is_utf8($str)) {
             # Avoid double-encoding UTF-8.
@@ -184,9 +181,9 @@
 sub _signature_method_class {
     my $self = shift;
     (my $signature_method = $self->signature_method) =~ s/\W+/_/g;
-    my $klass = 'Net::OAuth::SignatureMethod::' . $signature_method;
-    $klass->require or die "Unable to load $signature_method plugin";
-    return $klass;
+    my $sm_class = 'Net::OAuth::SignatureMethod::' . $signature_method;
+    die "Unable to load $signature_method plugin" unless Net::OAuth::smart_require($sm_class);
+    return $sm_class;
 }
 
 sub to_authorization_header {

Modified: branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Request.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Request.pm?rev=54149&op=diff
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Request.pm (original)
+++ branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/Request.pm Fri Mar 12 00:02:58 2010
@@ -5,7 +5,7 @@
 use URI;
 use URI::QueryParam;
 
-our $VERSION = '0.20';
+our $VERSION = '0.22';
 
 __PACKAGE__->mk_classdata(required_message_params => [qw/
     consumer_key

Added: branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/XauthAccessTokenRequest.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/XauthAccessTokenRequest.pm?rev=54149&op=file
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/XauthAccessTokenRequest.pm (added)
+++ branches/upstream/libnet-oauth-perl/current/lib/Net/OAuth/XauthAccessTokenRequest.pm Fri Mar 12 00:02:58 2010
@@ -1,0 +1,38 @@
+package Net::OAuth::XauthAccessTokenRequest;
+use warnings;
+use strict;
+use base 'Net::OAuth::Request';
+
+__PACKAGE__->add_extension_param_pattern(qr/x_auth_/);
+__PACKAGE__->add_required_message_params(qw/x_auth_username x_auth_password x_auth_mode/);
+sub allow_extra_params {0}
+sub sign_message {1}
+
+=head1 NAME
+
+Net::OAuth::xAuthAccessTokenRequest - xAuth extension
+
+=head1 SEE ALSO
+
+L<http://apiwiki.twitter.com/Twitter-REST-API-Method:-oauth-access_token-for-xAuth>
+
+=head1 AUTHOR
+
+Keith Grennan, C<< <kgrennan at cpan.org> >>
+
+=head1 CONTRIBUTORS
+
+Masayoshi Sekimura
+
+Simon Wistow
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2010 Keith Grennan, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;

Added: branches/upstream/libnet-oauth-perl/current/t/12-xauth.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-oauth-perl/current/t/12-xauth.t?rev=54149&op=file
==============================================================================
--- branches/upstream/libnet-oauth-perl/current/t/12-xauth.t (added)
+++ branches/upstream/libnet-oauth-perl/current/t/12-xauth.t Fri Mar 12 00:02:58 2010
@@ -1,0 +1,44 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+use Net::OAuth;
+
+my $request = Net::OAuth->request('xauth access token')->new(
+        consumer_key => 'dpf43f3p2l4k3l03',
+        consumer_secret => 'kd94hf93k423kf44',
+        request_url => 'https://photos.example.net/access_token',
+        request_method => 'POST',
+        signature_method => 'PLAINTEXT',
+        timestamp => '1191242092',
+        nonce => 'dji430splmx33448',
+        token => 'hh5s93j4hdidpola',
+        token_secret => 'hdhd0244k9j7ao03',
+        x_auth_username => 'keeth',
+        x_auth_password => 'foobar',
+        x_auth_mode => 'client_auth',
+);
+
+$request->sign;
+
+ok($request->verify);
+
+is($request->to_post_body, 'oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=dji430splmx33448&oauth_signature=kd94hf93k423kf44%26hdhd0244k9j7ao03&oauth_signature_method=PLAINTEXT&oauth_timestamp=1191242092&oauth_version=1.0&x_auth_mode=client_auth&x_auth_password=foobar&x_auth_username=keeth');
+
+eval {
+    $request = Net::OAuth->request('xauth access token')->new(
+            consumer_key => 'dpf43f3p2l4k3l03',
+            consumer_secret => 'kd94hf93k423kf44',
+            request_url => 'https://photos.example.net/access_token',
+            request_method => 'POST',
+            signature_method => 'PLAINTEXT',
+            timestamp => '1191242092',
+            nonce => 'dji430splmx33448',
+            token => 'hh5s93j4hdidpola',
+            token_secret => 'hdhd0244k9j7ao03',
+    );
+};
+
+ok($@);




More information about the Pkg-perl-cvs-commits mailing list