summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-09-13 16:14:18 +0200
committerfranck cuny <franck@lumberjaph.net>2010-09-13 16:14:18 +0200
commite7ea8cdaa2e33e019d6763065d39d7c1392b5802 (patch)
treeafc4e49bfe97db6e4b04e75671e6c630c16ce6be
parentremote trailings args (diff)
downloadnet-http-spore-e7ea8cdaa2e33e019d6763065d39d7c1392b5802.tar.gz
simple oauth middleware
-rw-r--r--lib/Net/HTTP/Spore/Middleware/Auth/OAuth.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Net/HTTP/Spore/Middleware/Auth/OAuth.pm b/lib/Net/HTTP/Spore/Middleware/Auth/OAuth.pm
index e30a45b..e389bed 100644
--- a/lib/Net/HTTP/Spore/Middleware/Auth/OAuth.pm
+++ b/lib/Net/HTTP/Spore/Middleware/Auth/OAuth.pm
@@ -15,6 +15,9 @@ has [qw/consumer_key consumer_secret token token_secret/] => (
 sub call {
     my ( $self, $req ) = @_;
 
+    return unless $req->env->{'spore.authentication'} == 1;
+
+    my $uri = $req->uri;
     my $request = Net::OAuth->request('protected resource')->new(
         version          => '1.0',
         consumer_key     => $self->consumer_key,
@@ -24,7 +27,7 @@ sub call {
         request_method   => $req->method,
         signature_method => 'HMAC-SHA1',
         timestamp        => time,
-        nonce            => MIME::Base64::encode( time . $$ . rand ),
+        nonce            => MIME::Base64::encode( time . $$ . rand, '' ),
         request_url      => $req->uri,
         # extra_params     => \%post_args,
     );