From 678262db3debb7f4d648794f5995d4d711932026 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 bb72af71c9..f36b8f77af 100644 --- a/C4/External/Amazon.pm +++ b/C4/External/Amazon.pm @@ -148,8 +148,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 250374ebf5..bb73d42fd9 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -231,6 +231,7 @@ $tabsysprefs{OPACAmazonEnabled} = "EnhancedContent"; $tabsysprefs{AmazonCoverImages} = "EnhancedContent"; $tabsysprefs{OPACAmazonCoverImages} = "EnhancedContent"; $tabsysprefs{AWSAccessKeyID} = "EnhancedContent"; +$tabsysprefs{AWSPrivateKey} = "EnhancedContent"; $tabsysprefs{AmazonLocale} = "EnhancedContent"; $tabsysprefs{AmazonAssocTag} = "EnhancedContent"; $tabsysprefs{AmazonSimilarItems} = "EnhancedContent"; -- 2.39.5