From e762bdb9b2243070fd33e9aeb1bdfb88f2af2193 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 17 Jul 2018 14:16:33 +0000 Subject: [PATCH] Bug 21082: Update OverDrive authentication method Testing will require an OverDrive account, you should be able to obtain a developer account here: https://developer.overdrive.com/ You will need to register a SIP connection for patron authentication To test authentication: 1 - Set authname default in OD prefs 2 - Sign in as a patron whose branch matches authname 3 - Verify the patron can sign into OverDrive 4 - Set the patrons branch authname to be incorrect 5 - Verify branch specific authname is used and patron cannot sign in 6 - Set the default authname to be incorrect and patron's branch authname to be correct 7 - Verofy patron can sign in To test circulation: 1 - Fill out all OD prefs and enable circulation 2 - Sign in to opac 3 - Verify you have an OverDrive tab 4 - Click 'Login to Overdrive' 5 - If password required you shoudl be prompted, otherwise you should be signed in and see account info 6 - Test logging out and in 7 - Log-in, perform a search on the opac - you should see hold/checkout buttons 8 - Test the buttons 9 - After holding/checking out items, check your account page 10 - Verify info is correct 11 - Log out of overdrive 12 - Search catalog click overdrive results 13 - Test "Login to Overdrive" link on OD results 14 - Verify page is reloaded, buttons show and work Signed-off-by: Sandy Allgood Signed-off-by: Chris Cormack Signed-off-by: Nick Clemens --- Koha/ExternalContent/OverDrive.pm | 28 +++++++++++++++++-- admin/overdrive.pl | 1 - .../en/modules/opac-overdrive-search.tt | 3 +- .../bootstrap/en/modules/opac-user.tt | 1 + koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js | 16 +++++++---- opac/svc/overdrive | 10 ++++++- 6 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Koha/ExternalContent/OverDrive.pm b/Koha/ExternalContent/OverDrive.pm index da84a4d19e..628e76122e 100644 --- a/Koha/ExternalContent/OverDrive.pm +++ b/Koha/ExternalContent/OverDrive.pm @@ -121,7 +121,7 @@ sub auth_url { =head2 auth_by_code($code, $base_url) - To be called in external/overdrive/auth.pl upon return from OverDrive auth + To be called in external/overdrive/auth.pl upon return from OverDrive Granted auth =cut @@ -141,6 +141,30 @@ sub auth_by_code { return $self->get_return_page_from_koha_session; } +=head2 auth_by_userid($userid, $password, $website_id, $authorization_name) + + To be called to check auth of patron using OverDrive Patron Authentication method + This requires a SIP connection configured with OverDrive + +=cut + +sub auth_by_userid { + my $self = shift; + my $userid = shift or croak "No user provided"; + my $password = shift; + croak "No password provided" unless ($password || !C4::Context->preference("OverDrivePasswordRequired")); + my $website_id = shift or croak "OverDrive Library ID not provided"; + my $authorization_name = shift or croak "OverDrive Authname not provided"; + + my ($access_token, $access_token_type, $auth_token) + = $self->client->auth_by_user_id($userid, $password, $website_id, $authorization_name); + $access_token or die "Invalid OverDrive code returned"; + $self->set_token_in_koha_session($access_token, $access_token_type); + + $self->koha_patron->set({overdrive_auth_token => $auth_token})->store; + return $self->get_return_page_from_koha_session; +} + use constant AUTH_RETURN_HANDLER => "/cgi-bin/koha/external/overdrive/auth.pl"; sub _return_url { my $self = shift; @@ -208,7 +232,7 @@ sub auth_by_saved_token { if (my $auth_token = $koha_patron->overdrive_auth_token) { my ($access_token, $access_token_type, $new_auth_token) - = $self->client->auth_by_token($auth_token); + = $self->client->make_access_token_request(); $self->set_token_in_koha_session($access_token, $access_token_type); $koha_patron->set({overdrive_auth_token => $new_auth_token})->store; return $access_token; diff --git a/admin/overdrive.pl b/admin/overdrive.pl index 489bf0ad40..c7359f263d 100755 --- a/admin/overdrive.pl +++ b/admin/overdrive.pl @@ -30,7 +30,6 @@ my $input = CGI->new; my @branchcodes = $input->multi_param('branchcode'); my @authnames = $input->multi_param('authname'); my $op = $input->param('op'); -my @messages; our ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => 'admin/overdrive.tt', diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt index f4154f93ef..1c2548bcef 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt @@ -64,6 +64,7 @@ [% Asset.js("js/overdrive.js") | $raw %] [% Asset.js("lib/jquery/plugins/jquery.rating.js") | $raw %]