Bugzilla – Attachment 75184 Details for
Bug 20624
Disable the OAuth2 client credentials grant by default
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20624: Net::OAuth2::AuthorizationServer is not a hard dependency
Bug-20624-NetOAuth2AuthorizationServer-is-not-a-ha.patch (text/plain), 3.24 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-05-08 18:32:18 UTC
(
hide
)
Description:
Bug 20624: Net::OAuth2::AuthorizationServer is not a hard dependency
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-05-08 18:32:18 UTC
Size:
3.24 KB
patch
obsolete
>From f1bfa37b92dd4db3318f7d6c24f77e6db2af6e48 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 8 May 2018 14:58:55 -0300 >Subject: [PATCH] Bug 20624: Net::OAuth2::AuthorizationServer is not a hard > dependency > >While we get packaging sorted, Net::OAuth2::AuthorizationServer is not a >hard dependency for Koha and the feature requiring it is disabled by >default. > >This patch: >- Makes the dependency optional >- Makes the unit tests for the OAuth2 client credentials flow skip if > the dependency is not met. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Installer/PerlDependencies.pm | 2 +- > Koha/REST/V1/Auth.pm | 3 ++- > Koha/REST/V1/OAuth.pm | 3 ++- > t/db_dependent/api/v1/oauth.t | 13 ++++++++++++- > 4 files changed, 17 insertions(+), 4 deletions(-) > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index ffc8661380..6229742b65 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -890,7 +890,7 @@ our $PERL_DEPS = { > }, > 'Net::OAuth2::AuthorizationServer' => { > usage => 'REST API', >- required => '1', >+ required => '0', > min_ver => '0.16', > }, > }; >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index b2ccd6b59e..afbe468288 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -120,7 +120,8 @@ sub authenticate_api_request { > > if ($authorization_header and $authorization_header =~ /^Bearer /) { > # attempt to use OAuth2 authentication >- if ( ! Module::Load::Conditional::can_load('Net::OAuth2::AuthorizationServer') ) { >+ if ( ! Module::Load::Conditional::can_load( >+ modules => {'Net::OAuth2::AuthorizationServer' => undef} )) { > Koha::Exceptions::Authorization::Unauthorized->throw( > error => 'Authentication failure.' > ); >diff --git a/Koha/REST/V1/OAuth.pm b/Koha/REST/V1/OAuth.pm >index 3679dbecdc..b75c89243c 100644 >--- a/Koha/REST/V1/OAuth.pm >+++ b/Koha/REST/V1/OAuth.pm >@@ -40,7 +40,8 @@ sub token { > > my $c = shift->openapi->valid_input or return; > >- if ( Module::Load::Conditional::can_load('Net::OAuth2::AuthorizationServer') ) { >+ if ( Module::Load::Conditional::can_load( >+ modules => {'Net::OAuth2::AuthorizationServer' => undef} )) { > require Net::OAuth2::AuthorizationServer; > } > else { >diff --git a/t/db_dependent/api/v1/oauth.t b/t/db_dependent/api/v1/oauth.t >index 2748fe25b3..16e273cedd 100755 >--- a/t/db_dependent/api/v1/oauth.t >+++ b/t/db_dependent/api/v1/oauth.t >@@ -17,10 +17,13 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More; > use Test::MockModule; > use Test::Mojo; > >+use Module::Load::Conditional qw(can_load); >+ >+use Koha::ApiKeys; > use Koha::Database; > use Koha::Patrons; > >@@ -31,7 +34,15 @@ my $t = Test::Mojo->new('Koha::REST::V1'); > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new(); > >+if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { >+ plan tests => 2; >+} >+else { >+ plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; >+} >+ > subtest '/oauth/token tests' => sub { >+ > plan tests => 27; > > $schema->storage->txn_begin; >-- >2.17.0
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 20624
:
74986
|
74987
|
74988
|
74989
|
75020
|
75021
|
75060
|
75061
|
75062
|
75063
|
75064
|
75065
|
75132
| 75184 |
75206