Bug 20734: Add warning to the about page if RESTOAuth2ClientCredentials and not Net...
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 9 May 2018 14:31:34 +0000 (11:31 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 9 May 2018 15:56:03 +0000 (12:56 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

about.pl
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref

index 3997d49..b3cad66 100755 (executable)
--- 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')
index c35a01e..abcd8c3 100644 (file)
         </div>
 
         <div id="sysinfo">
-    [% 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) %]
             <h2>Warning regarding current user</h2>
             <p>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.</p>
             <br/>
         [% 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 %]
             <h2>Warnings regarding the system configuration</h2>
             <table>
                 <caption>Preferences and parameters</caption>
                     </td></tr>
                   [% END %]
                 [% END %]
+                [% IF oauth2_missing_deps %]
+                    <tr><th scope="row"><b>Warning</b> </th><td>
+                    System preference 'RESTOAuth2ClientCredentials' is set, but the required Net::OAuth2::AuthorizationServer dependency is missing. The feature is disabled.
+                    </td></tr>
+                [% END %]
             </table>
         [% END %]
 
index d9ad25f..6b415f2 100644 (file)
@@ -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