View | Details | Raw Unified | Return to bug 25411
Collapse All | Expand All

(-)a/Koha/REST/V1/Auth.pm (-4 / +13 lines)
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
        }
73
74
        if ( $namespace eq 'contrib' ) {
75
            $is_plugin = 1;
76
        }
67
77
68
        if ( $is_public
78
        if ( $is_public
69
            and !C4::Context->preference('RESTPublicAPI') )
79
            and !C4::Context->preference('RESTPublicAPI') )
Lines 80-86 sub under { Link Here
80
            $status = 1;
90
            $status = 1;
81
        }
91
        }
82
        else {
92
        else {
83
            $status = authenticate_api_request($c, { is_public => $is_public });
93
            $status = authenticate_api_request($c, { is_public => $is_public, is_plugin => $is_plugin });
84
        }
94
        }
85
95
86
    } catch {
96
    } catch {
Lines 242-248 sub authenticate_api_request { Link Here
242
    if ( !$authorization and
252
    if ( !$authorization and
243
         ( $params->{is_public} and
253
         ( $params->{is_public} and
244
          ( C4::Context->preference('RESTPublicAnonymousRequests') or
254
          ( C4::Context->preference('RESTPublicAnonymousRequests') or
245
            $user) ) ) {
255
            $user) ) or $params->{is_plugin} ) {
246
        # We do not need any authorization
256
        # We do not need any authorization
247
        # Check the parameters
257
        # Check the parameters
248
        validate_query_parameters( $c, $spec );
258
        validate_query_parameters( $c, $spec );
249
- 

Return to bug 25411