Bugzilla – Attachment 45667 Details for
Bug 10988
Allow login via Google OAuth2 (OpenID Connect)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10988: Dealt with borrower flag issues
Bug-10988-Dealt-with-borrower-flag-issues.patch (text/plain), 4.56 KB, created by
Mark Tompsett
on 2015-12-14 15:42:33 UTC
(
hide
)
Description:
Bug 10988: Dealt with borrower flag issues
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-12-14 15:42:33 UTC
Size:
4.56 KB
patch
obsolete
>From f453ff55f5396cd5b27f0263d4adfcef5b97abe3 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Mon, 14 Dec 2015 10:40:03 -0500 >Subject: [PATCH] Bug 10988: Dealt with borrower flag issues > >Removed borrower flag reference in template grab, and >emptied it in the checkauth call. Personal retesting worked. >Also, made it perlcritic prettier. >--- > opac/svc/auth/googleoauth2 | 47 ++++++++++++++++++++++------------------------ > 1 file changed, 22 insertions(+), 25 deletions(-) > >diff --git a/opac/svc/auth/googleoauth2 b/opac/svc/auth/googleoauth2 >index 07ff084..87fba6f 100755 >--- a/opac/svc/auth/googleoauth2 >+++ b/opac/svc/auth/googleoauth2 >@@ -46,9 +46,9 @@ use LWP::UserAgent; > use HTTP::Request::Common qw{ POST }; > use JSON; > >-my $scope = "openid email"; >-my $host = C4::Context->preference('OPACBaseURL') // ''; >-my $restricttodomain = C4::Context->preference('GoogleOAuth2Domain') // ''; >+my $scope = 'openid email'; >+my $host = C4::Context->preference('OPACBaseURL') // q{}; >+my $restricttodomain = C4::Context->preference('GoogleOAuth2Domain') // q{}; > > # protocol is assumed in OPACBaseURL see bug 5010. > my $redirecturl = $host . '/cgi-bin/koha/svc/auth/googleoauth2'; >@@ -56,25 +56,25 @@ my $issuer = 'accounts.google.com'; > my $clientid = C4::Context->preference('GoogleOAuth2ClientID'); > my $clientsecret = C4::Context->preference('GoogleOAuth2ClientSecret'); > >-my $query = new CGI; >+my $query = CGI->new; > > sub loginfailed { >- my $query = shift; >- my $reason = shift; >- $query->delete('code'); >- $query->param( 'OAuth2Failed' => $reason ); >+ my $cgi_query = shift; >+ my $reason = shift; >+ $cgi_query->delete('code'); >+ $cgi_query->param( 'OAuth2Failed' => $reason ); > my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > { > template_name => 'opac-user.tt', >- query => $query, >+ query => $cgi_query, > type => 'opac', > authnotrequired => 0, >- flagsrequired => { borrow => 1 }, > } > ); > $template->param( 'invalidOAuth2Login' => $reason ); > $template->param( 'loginprompt' => 1 ); >- output_html_with_http_headers $query, $cookie, $template->output; >+ output_html_with_http_headers $cgi_query, $cookie, $template->output; >+ return; > } > > if ( defined $query->param('error') ) { >@@ -94,7 +94,7 @@ elsif ( defined $query->param('code') ) { > client_secret => $clientsecret, > redirect_uri => $redirecturl, > grant_type => 'authorization_code', >- $scope => $scope >+ $scope => $scope > ] > ); > my $response = $ua->request($request)->decoded_content; >@@ -111,11 +111,11 @@ elsif ( defined $query->param('code') ) { > && exists( $json->{'email'} ) ) > { > my $email = $json->{'email'}; >- my ( $userid, $cookie, $sessionID ) = >- checkauth( $query, 1, { borrow => 1 }, 'opac', $email ); >+ my ( $userid, $cookie, $session_id ) = >+ checkauth( $query, 1, { }, 'opac', $email ); > if ($userid) { # A valid user has logged in >- if ( ( $restricttodomain ne '' ) >- && ( index( $email, $restricttodomain ) == -1 ) ) >+ if ( ( $restricttodomain ne q{} ) >+ && ( index( $email, $restricttodomain ) < 0 ) ) > { > loginfailed( $query, > 'The email you have used is not valid for this library. Email addresses should conclude with ' >@@ -148,22 +148,19 @@ elsif ( defined $query->param('code') ) { > > } > else { >- my $prompt = ''; >- $prompt = $query->param('reauthenticate') >- unless not( defined $query->param('reauthenticate') ); >+ my $prompt = $query->param('reauthenticate') // q{}; > > my $authorisationurl = > 'https://accounts.google.com/o/oauth2/auth?' > . 'response_type=code&' > . 'redirect_uri=' >- . escape($redirecturl) . '&' >+ . escape($redirecturl) . q{&} > . 'client_id=' >- . escape($clientid) . '&' >+ . escape($clientid) . q{&} > . 'scope=' >- . escape($scope) . '&'; >- if ( $query->param('reauthenticate') ) { >- $authorisationurl .= >- 'prompt=' . escape( $query->param('reauthenticate') ); >+ . escape($scope) . q{&}; >+ if ( $prompt || ( defined $prompt && length $prompt > 0 ) ) { >+ $authorisationurl .= 'prompt=' . escape($prompt); > } > print $query->redirect($authorisationurl); > } >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10988
:
21740
|
21936
|
21938
|
21939
|
25343
|
25570
|
25684
|
29594
|
29595
|
30014
|
30015
|
36354
|
36355
|
40087
|
40252
|
40442
|
40979
|
41663
|
43791
|
43792
|
43938
|
45667
|
45668
|
45895
|
46016
|
46473
|
46474
|
47780
|
47781
|
47782
|
49785
|
49786
|
49787