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

(-)a/Koha/REST/V1/Auth.pm (-5 / +8 lines)
Lines 63-70 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
67
        if ( $namespace eq 'public'
68
        if ( $is_public
68
            and !C4::Context->preference('RESTPublicAPI') )
69
            and !C4::Context->preference('RESTPublicAPI') )
69
        {
70
        {
70
            Koha::Exceptions::Authorization->throw(
71
            Koha::Exceptions::Authorization->throw(
Lines 76-82 sub under { Link Here
76
            $status = 1;
77
            $status = 1;
77
        }
78
        }
78
        else {
79
        else {
79
            $status = authenticate_api_request($c);
80
            $status = authenticate_api_request($c, { is_public => $is_public });
80
        }
81
        }
81
82
82
    } catch {
83
    } catch {
Lines 132-138 if authorization is required and user has required permissions to access. Link Here
132
=cut
133
=cut
133
134
134
sub authenticate_api_request {
135
sub authenticate_api_request {
135
    my ( $c ) = @_;
136
    my ( $c, $params ) = @_;
136
137
137
    my $user;
138
    my $user;
138
139
Lines 235-241 sub authenticate_api_request { Link Here
235
236
236
    $c->stash('koha.user' => $user);
237
    $c->stash('koha.user' => $user);
237
238
238
    if ( !$authorization ) {
239
    if ( !$authorization and
240
         ( $params->{is_public} and
241
          ( C4::Context->preference('RESTPublicAnonymousRequests') or
242
            $user) ) ) {
239
        # We do not need any authorization
243
        # We do not need any authorization
240
        # Check the parameters
244
        # Check the parameters
241
        validate_query_parameters( $c, $spec );
245
        validate_query_parameters( $c, $spec );
242
- 

Return to bug 25045