From 59885320579b0116faa5bd6153a3a3c7f7e8af3c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 9 May 2018 11:31:34 -0300 Subject: [PATCH] Bug 20734: Add warning to the about page if RESTOAuth2ClientCredentials and not Net::OAuth2::AuthorizationServer Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- about.pl | 8 ++++++++ koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 9 +++++++-- .../prog/en/modules/admin/preferences/web_services.pref | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/about.pl b/about.pl index 3997d4992a..b3cad66325 100755 --- a/about.pl +++ b/about.pl @@ -26,6 +26,7 @@ use CGI qw ( -utf8 ); use DateTime::TimeZone; use List::MoreUtils qw/ any /; use LWP::Simple; +use Module::Load::Conditional qw(can_load); use XML::Simple; use Config; use Search::Elasticsearch; @@ -391,6 +392,13 @@ if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { } } +if ( C4::Context->preference('RESTOAuth2ClientCredentials') ) { + # Do we have the required deps? + unless ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef }) ) { + $template->param( oauth2_missing_deps => 1 ); + } +} + # Sco Patron should not contain any other perms than circulate => self_checkout if ( C4::Context->preference('WebBasedSelfCheck') and C4::Context->preference('AutoSelfCheckAllowed') diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index c35a01ef87..abcd8c3587 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -183,7 +183,7 @@
- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps %] [% IF (warnIsRootUser) %]

Warning regarding current user

You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.

@@ -228,7 +228,7 @@
[% END %] - [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps %]

Warnings regarding the system configuration

@@ -295,6 +295,11 @@ [% END %] [% END %] + [% IF oauth2_missing_deps %] + + [% END %]
Preferences and parameters
Warning + System preference 'RESTOAuth2ClientCredentials' is set, but the required Net::OAuth2::AuthorizationServer dependency is missing. The feature is disabled. +
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index d9ad25fb52..6b415f212c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -10,7 +10,7 @@ Web services: choices: yes: Enable no: "Disable" - - "the OAuth2 client credentials grant for the REST API." + - "the OAuth2 client credentials grant for the REST API. Requires Net::OAuth2::AuthorizationServer installed. [EXPERIMENTAL]" OAI-PMH: - - pref: OAI-PMH -- 2.11.0