From 414f8f91b4428f9bc093aaa4954f5ac852db556d Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 13 Aug 2009 09:25:34 -0400 Subject: [PATCH] bug 3204: tweaks to AWS request signing * Add AWSPrivateKey system preference to the Enhanced Content tab in the syspref editor * Now warns to log if attempting to use the Amazon API without setting AWSPrivateKey Signed-off-by: Galen Charlton --- C4/External/Amazon.pm | 10 ++++++++-- admin/systempreferences.pl | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/C4/External/Amazon.pm b/C4/External/Amazon.pm index afd819a886..492577cc1d 100644 --- a/C4/External/Amazon.pm +++ b/C4/External/Amazon.pm @@ -118,8 +118,14 @@ sub get_amazon_details { push @params, qq{$key=}.uri_escape($value, "^A-Za-z0-9\-_.~" ); } - my $url =qq{http://webservices.amazon}. get_amazon_tld(). - "/onca/xml?".join("&",sort @params).qq{&Signature=}.uri_escape(SignRequest(@params),"^A-Za-z0-9\-_.~" ); + my $url; + if (C4::Context->preference('AWSPrivateKey')) { + $url = qq{http://webservices.amazon} . get_amazon_tld() . + "/onca/xml?" . join("&",sort @params) . qq{&Signature=} . uri_escape(SignRequest(@params),"^A-Za-z0-9\-_.~" ); + } else { + $url = qq{http://webservices.amazon} . get_amazon_tld() . "/onca/xml?" .join("&",sort @params); + warn "MUST set AWSPrivateKey syspref after 2009-08-15 in order to access Amazon web services"; + } my $content = get($url); warn "could not retrieve $url" unless $content; diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 2ef6dad239..904fb4b940 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -214,6 +214,7 @@ $tabsysprefs{AdvancedSearchTypes} = "Searching"; # EnhancedContent $tabsysprefs{AmazonContent} = "EnhancedContent"; $tabsysprefs{AWSAccessKeyID} = "EnhancedContent"; +$tabsysprefs{AWSPrivateKey} = "EnhancedContent"; $tabsysprefs{AmazonLocale} = "EnhancedContent"; $tabsysprefs{AmazonAssocTag} = "EnhancedContent"; $tabsysprefs{AmazonSimilarItems} = "EnhancedContent"; -- 2.39.5