Lines 55-68
This subroutine is called before every request to API.
Link Here
|
55 |
=cut |
55 |
=cut |
56 |
|
56 |
|
57 |
sub under { |
57 |
sub under { |
58 |
my $c = shift->openapi->valid_input or return;; |
58 |
my ( $c ) = @_; |
59 |
|
59 |
|
60 |
my $status = 0; |
60 |
my $status = 0; |
61 |
|
61 |
|
62 |
try { |
62 |
try { |
63 |
|
63 |
|
64 |
# /api/v1/{namespace} |
64 |
# /api/v1/{namespace} |
65 |
my $namespace = $c->req->url->to_abs->path->[2]; |
65 |
my $namespace = $c->req->url->to_abs->path->[2] // ''; |
66 |
|
66 |
|
67 |
if ( $namespace eq 'public' |
67 |
if ( $namespace eq 'public' |
68 |
and !C4::Context->preference('RESTPublicAPI') ) |
68 |
and !C4::Context->preference('RESTPublicAPI') ) |
Lines 136-142
sub authenticate_api_request {
Link Here
|
136 |
|
136 |
|
137 |
my $user; |
137 |
my $user; |
138 |
|
138 |
|
139 |
my $spec = $c->match->endpoint->pattern->defaults->{'openapi.op_spec'}; |
139 |
# The following supports retrieval of spec with Mojolicious::Plugin::OpenAPI@1.17 and later (first one) |
|
|
140 |
# and older versions (second one). |
141 |
# TODO: remove the latter 'openapi.op_spec' if minimum version is bumped to at least 1.17. |
142 |
my $spec = $c->openapi->spec || $c->match->endpoint->pattern->defaults->{'openapi.op_spec'}; |
140 |
my $authorization = $spec->{'x-koha-authorization'}; |
143 |
my $authorization = $spec->{'x-koha-authorization'}; |
141 |
|
144 |
|
142 |
my $authorization_header = $c->req->headers->authorization; |
145 |
my $authorization_header = $c->req->headers->authorization; |
143 |
- |
|
|