@@ -, +, @@ the patches above into one, making them apply to master again. 0) Back up your database 1) Apply all these patches 2) In your mysql client use your Koha database and execute: > DELETE FROM systempreferences; > SOURCE ~/kohaclone/installer/data/mysql/sysprefs.sql; -- Should be no errors. > SELECT * FROM systempreferences LIKE 'GoogleOAuth%'; -- Should see 4 entries. > QUIT; 3) Restore your database 4) Run ./installer/data/mysql/updatedatabase.pl; 5) In your mysql client use your Koha database and execute: > SELECT * FROM systempreferences LIKE 'GoogleOAuth%'; -- Should see the same 4 entries. 6) Log into the staff client 7) Home -> Koha administration -> Global system preferences 8) -> OPAC -- make sure your OPACBaseURL is set (e.g. https://opac.koha.ca) 9) -> Administration -- There should be a 'Google OAuth2' section with the ability to set those 4 system preferences. library name (e.g. South Pole Library). (e.g. South Pole Library Authentication) (http://library.yourDNS.org) googleoauth2 script (http://library.yourDNS.org/cgi-bin/koha/svc/auth/googleoauth2) system preference. system preference. -- You should get a confirmation request, if you are already logged in, OR a login screen if you are not. -- You need to have the primary email address set to one authenticated by Google in order to log in. --- C4/Auth.pm | 7 + installer/data/mysql/atomicupdate/googleoauth2.sql | 5 + installer/data/mysql/sysprefs.sql | 4 + .../prog/en/modules/admin/preferences/admin.pref | 18 +++ .../opac-tmpl/bootstrap/en/includes/masthead.inc | 4 + .../opac-tmpl/bootstrap/en/modules/opac-auth.tt | 9 ++ opac/svc/auth/googleoauth2 | 166 +++++++++++++++++++++ 7 files changed, 213 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/googleoauth2.sql create mode 100755 opac/svc/auth/googleoauth2 --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -1285,6 +1285,13 @@ sub checkauth { ); } + if (C4::Context->preference('GoogleOAuth2')) { + if ($query->param("OAuth2Failed")) { + my $reason = $query->param('OAuth2Failed'); + $template->param(invalidOAuth2Login => $reason); + } + } + $template->param( LibraryName => C4::Context->preference("LibraryName"), ); --- a/installer/data/mysql/atomicupdate/googleoauth2.sql +++ a/installer/data/mysql/atomicupdate/googleoauth2.sql @@ -0,0 +1,5 @@ +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES + ('GoogleOAuth2', '0', NULL, 'if ON, allows the use of Google OAuth2 for login', 'YesNo'), + ('GoogleOAuth2ClientID', '', NULL, 'Client ID for the web app registered with google', 'Free'), + ('GoogleOAuth2ClientSecret', '', NULL, 'Client Secret for the web app registered with google', 'Free'), + ('GoogleOAuth2Domain', '', NULL, 'Restrict OAuth2 to this domain (or subdomains of this domain). Leave blank for all google domains', 'Free'); --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -147,6 +147,10 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('gist','0','','Default Goods and Services tax rate NOT in %, but in numeric form (0.12 for 12%), set to 0 to disable GST','Integer'), ('GoogleIndicTransliteration','0','','GoogleIndicTransliteration on the OPAC.','YesNo'), ('GoogleJackets','0',NULL,'if ON, displays jacket covers from Google Books API','YesNo'), +('GoogleOAuth2', '0', NULL, 'if ON, allows the use of Google OAuth2 for login', 'YesNo'), +('GoogleOAuth2ClientID', '', NULL, 'Client ID for the web app registered with google', 'Free'), +('GoogleOAuth2ClientSecret', '', NULL, 'Client Secret for the web app registered with google', 'Free'), +('GoogleOAuth2Domain', '', NULL, 'Restrict OAuth2 to this domain (or subdomains of this domain). Leave blank for all google domains', 'Free'), ('hidelostitems','0','','If ON, disables display of\"lost\" items in OPAC.','YesNo'), ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), ('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -121,6 +121,24 @@ Administration: Common Name: the Common Name emailAddress: the emailAddress - field for SSL client certificate authentication + Google OAuth2: + - + - pref: GoogleOAuth2 + choices: + yes: Use + no: "Don't Use" + - Google OAuth2 login. + - You will need to select OAuth2 when creating an app in the google cloud console, and set the web origin to your_opac_url and the redirect url to your_opac_url/cgi-bin/koha/svc/auth/googleoauth2 . + - + - Google OAuth2 Client ID + - pref: GoogleOAuth2ClientID + - + - Google OAuth2 Client Secret + - pref: GoogleOAuth2ClientSecret + - + - Google OAuth2 Restrict to domain (or subdomain of this domain) + - pref: GoogleOAuth2Domain + - . Leave blank for all google domains Mozilla Persona: - - pref: Persona --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -65,6 +65,8 @@ [% IF some_private_shelves > 10 %]
Sorry, your automatic login failed. [% invalidOAuth2Login %]
+Please note that the automatic login will only work if you are using the e-mail address registered with this library.
+If you want to, you can try to log in using a different account +
If you can't log in automatically, but you do have a local account, you can still log in:
+ [% END %] +