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

(-)a/Koha/REST/Plugin/Query.pm (-24 / +5 lines)
Lines 145-151 Generates the DBIC prefetch attribute based on embedded relations, and merges in Link Here
145
            my $attributes = $args->{attributes};
145
            my $attributes = $args->{attributes};
146
            my $result_set = $args->{result_set};
146
            my $result_set = $args->{result_set};
147
            my $embed = $c->stash('koha.embed');
147
            my $embed = $c->stash('koha.embed');
148
149
            return unless defined $embed;
148
            return unless defined $embed;
150
149
151
            my @prefetches;
150
            my @prefetches;
Lines 229-269 Merges parameters from $q_params into $filtered_params. Link Here
229
228
230
=head3 stash_embed
229
=head3 stash_embed
231
230
232
    $c->stash_embed( $c->match->endpoint->pattern->defaults->{'openapi.op_spec'} );
231
    $c->stash_embed( );
233
232
234
=cut
233
=cut
235
234
236
    $app->helper(
235
    $app->helper(
237
        'stash_embed' => sub {
236
        'stash_embed' => sub {
238
237
239
            my ( $c, $args ) = @_;
238
            my ( $c ) = @_;
240
241
            my $spec = $args->{spec} // {};
242
243
            my $embed_spec;
244
            for my $param (@{$spec->{parameters}}) {
245
                next unless $param->{name} eq 'x-koha-embed';
246
                $embed_spec = $param->{items}->{enum};
247
            }
248
            my $embed_header = $c->req->headers->header('x-koha-embed');
239
            my $embed_header = $c->req->headers->header('x-koha-embed');
249
240
            if ($embed_header) {
250
            Koha::Exceptions::BadParameter->throw("Embedding objects is not allowed on this endpoint.")
251
                if $embed_header and !defined $embed_spec;
252
253
            if ( $embed_header ) {
254
                my $THE_embed = {};
241
                my $THE_embed = {};
255
                foreach my $embed_req ( split /\s*,\s*/, $embed_header ) {
242
                foreach my $embed_req ( split /\s*,\s*/, $embed_header ) {
256
                    my $matches = grep {lc $_ eq lc $embed_req} @{ $embed_spec };
243
                    _merge_embed( _parse_embed($embed_req), $THE_embed );
257
258
                    Koha::Exceptions::BadParameter->throw(
259
                        error => 'Embeding '.$embed_req. ' is not authorised. Check your x-koha-embed headers or remove it.'
260
                    ) unless $matches;
261
262
                    _merge_embed( _parse_embed($embed_req), $THE_embed);
263
                }
244
                }
264
245
265
                $c->stash( 'koha.embed' => $THE_embed )
246
                $c->stash( 'koha.embed' => $THE_embed )
266
                    if $THE_embed;
247
                  if $THE_embed;
267
            }
248
            }
268
249
269
            return $c;
250
            return $c;
(-)a/Koha/REST/V1/Auth.pm (-2 / +1 lines)
Lines 157-163 sub authenticate_api_request { Link Here
157
    # TODO: remove the latter 'openapi.op_spec' if minimum version is bumped to at least 1.17.
157
    # TODO: remove the latter 'openapi.op_spec' if minimum version is bumped to at least 1.17.
158
    my $spec = $c->openapi->spec || $c->match->endpoint->pattern->defaults->{'openapi.op_spec'};
158
    my $spec = $c->openapi->spec || $c->match->endpoint->pattern->defaults->{'openapi.op_spec'};
159
159
160
    $c->stash_embed({ spec => $spec });
160
    $c->stash_embed();
161
    $c->stash_overrides();
161
    $c->stash_overrides();
162
162
163
    my $cookie_auth = 0;
163
    my $cookie_auth = 0;
164
- 

Return to bug 30536