Lines 21-26
use Module::Load::Conditional;
Link Here
|
21 |
|
21 |
|
22 |
use C4::Context; |
22 |
use C4::Context; |
23 |
use Koha::OAuth; |
23 |
use Koha::OAuth; |
|
|
24 |
use MIME::Base64; |
24 |
|
25 |
|
25 |
use Mojo::Base 'Mojolicious::Controller'; |
26 |
use Mojo::Base 'Mojolicious::Controller'; |
26 |
|
27 |
|
Lines 53-60
sub token {
Link Here
|
53 |
return $c->render(status => 400, openapi => {error => 'Unimplemented grant type'}); |
54 |
return $c->render(status => 400, openapi => {error => 'Unimplemented grant type'}); |
54 |
} |
55 |
} |
55 |
|
56 |
|
56 |
my $client_id = $c->validation->param('client_id'); |
57 |
my $client_id; |
57 |
my $client_secret = $c->validation->param('client_secret'); |
58 |
my $client_secret; |
|
|
59 |
|
60 |
my $authorization_header = $c->req->headers->authorization; |
61 |
|
62 |
if ( $authorization_header and $authorization_header =~ /^Basic / ) { |
63 |
my ( $type, $credentials ) = split / /, $authorization_header; |
64 |
|
65 |
unless ($credentials) { |
66 |
Koha::Exceptions::Authentication::Required->throw( error => 'Authentication failure.' ); |
67 |
} |
68 |
|
69 |
my $decoded_credentials = decode_base64( $credentials ); |
70 |
( $client_id, $client_secret ) = split( /:/, $decoded_credentials, 2 ); |
71 |
} |
72 |
else { |
73 |
$client_id = $c->validation->param('client_id'); |
74 |
$client_secret = $c->validation->param('client_secret'); |
75 |
} |
58 |
|
76 |
|
59 |
my $cb = "${grant_type}_grant"; |
77 |
my $cb = "${grant_type}_grant"; |
60 |
my $server = Net::OAuth2::AuthorizationServer->new; |
78 |
my $server = Net::OAuth2::AuthorizationServer->new; |
61 |
- |
|
|