|
Lines 63-69
sub under {
Link Here
|
| 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 |
my $is_public = ($namespace eq 'public') ? 1 : 0; |
66 |
|
|
|
67 |
my $is_public = 0; # By default routes are not public |
| 68 |
my $is_plugin = 0; |
| 69 |
|
| 70 |
if ( $namespace eq 'public' ) { |
| 71 |
$is_public = 1; |
| 72 |
} elsif ( $namespace eq 'contrib' ) { |
| 73 |
$is_plugin = 1; |
| 74 |
} |
| 67 |
|
75 |
|
| 68 |
if ( $is_public |
76 |
if ( $is_public |
| 69 |
and !C4::Context->preference('RESTPublicAPI') ) |
77 |
and !C4::Context->preference('RESTPublicAPI') ) |
|
Lines 80-86
sub under {
Link Here
|
| 80 |
$status = 1; |
88 |
$status = 1; |
| 81 |
} |
89 |
} |
| 82 |
else { |
90 |
else { |
| 83 |
$status = authenticate_api_request($c, { is_public => $is_public }); |
91 |
$status = authenticate_api_request($c, { is_public => $is_public, is_plugin => $is_plugin }); |
| 84 |
} |
92 |
} |
| 85 |
|
93 |
|
| 86 |
} catch { |
94 |
} catch { |
|
Lines 240-246
sub authenticate_api_request {
Link Here
|
| 240 |
if ( !$authorization and |
248 |
if ( !$authorization and |
| 241 |
( $params->{is_public} and |
249 |
( $params->{is_public} and |
| 242 |
( C4::Context->preference('RESTPublicAnonymousRequests') or |
250 |
( C4::Context->preference('RESTPublicAnonymousRequests') or |
| 243 |
$user) ) ) { |
251 |
$user) ) or $params->{is_plugin} ) { |
| 244 |
# We do not need any authorization |
252 |
# We do not need any authorization |
| 245 |
# Check the parameters |
253 |
# Check the parameters |
| 246 |
validate_query_parameters( $c, $spec ); |
254 |
validate_query_parameters( $c, $spec ); |
| 247 |
- |
|
|