Lines 1-17
Link Here
|
1 |
package Koha::REST::V1::OAuth; |
1 |
package Koha::REST::V1::OAuth; |
2 |
|
2 |
|
|
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Koha is free software; you can redistribute it and/or modify it under the |
6 |
# terms of the GNU General Public License as published by the Free Software |
7 |
# Foundation; either version 3 of the License, or (at your option) any later |
8 |
# version. |
9 |
# |
10 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
11 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
12 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
13 |
# |
14 |
# You should have received a copy of the GNU General Public License along |
15 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
16 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 |
|
3 |
use Modern::Perl; |
18 |
use Modern::Perl; |
4 |
|
19 |
|
5 |
use Mojo::Base 'Mojolicious::Controller'; |
20 |
use Module::Load::Conditional; |
6 |
|
21 |
|
7 |
use Net::OAuth2::AuthorizationServer; |
22 |
use C4::Context; |
8 |
use Koha::OAuth; |
23 |
use Koha::OAuth; |
9 |
|
24 |
|
10 |
use C4::Context; |
25 |
use Mojo::Base 'Mojolicious::Controller'; |
11 |
|
26 |
|
12 |
sub token { |
27 |
sub token { |
|
|
28 |
|
13 |
my $c = shift->openapi->valid_input or return; |
29 |
my $c = shift->openapi->valid_input or return; |
14 |
|
30 |
|
|
|
31 |
if ( Module::Load::Conditional::can_load('Net::OAuth2::AuthorizationServer') ) { |
32 |
require Net::OAuth2::AuthorizationServer; |
33 |
} |
34 |
else { |
35 |
return $c->render( status => 400, openapi => { error => 'Unimplemented grant type' } ); |
36 |
} |
37 |
|
15 |
my $grant_type = $c->validation->param('grant_type'); |
38 |
my $grant_type = $c->validation->param('grant_type'); |
16 |
unless ( $grant_type eq 'client_credentials' and C4::Context->preference('RESTOAuth2ClientCredentials') ) { |
39 |
unless ( $grant_type eq 'client_credentials' and C4::Context->preference('RESTOAuth2ClientCredentials') ) { |
17 |
return $c->render(status => 400, openapi => {error => 'Unimplemented grant type'}); |
40 |
return $c->render(status => 400, openapi => {error => 'Unimplemented grant type'}); |
18 |
- |
|
|