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

(-)a/Koha/REST/Plugin/Query.pm (+35 lines)
Lines 143-148 is raised. Link Here
143
            return $params;
143
            return $params;
144
        }
144
        }
145
    );
145
    );
146
147
=head3 stash_embed
148
149
    $c->stash_embed( $c->match->endpoint->pattern->defaults->{'openapi.op_spec'} );
150
151
=cut
152
153
    $app->helper(
154
        'stash_embed' => sub {
155
156
            my ( $c, $spec ) = @_;
157
158
            my $embed_spec   = $spec->{'x-koha-embed'};
159
            my $embed_header = $c->req->headers->header('x-koha-embed');
160
161
            Koha::Exceptions::WrongParameter->throw("Embedding objects is not allowed on this endpoint")
162
                if $embed_header and !defined $embed_spec;
163
164
            my @to_embed;
165
            foreach my $embed_req ( split /\s*,\s*/, $embed_header ) {
166
                my $matches = grep {lc $_ eq lc $embed_req} @{ $embed_req };
167
168
                Koha::Exceptions::WrongParameter->throw(
169
                    error => 'Embeding '.$embed_req. ' is not authorised. Check your x-koha-embed headers or remove it.'
170
                ) unless $matches;
171
172
                push @to_embed, $embed_req;
173
            }
174
175
            $c->stash( 'koha.embed' => \@to_embed )
176
                if scalar @to_embed > 0;
177
178
            return $c;
179
        }
180
    );
146
}
181
}
147
182
148
=head2 Internal methods
183
=head2 Internal methods
(-)a/Koha/REST/V1/Auth.pm (-1 / +3 lines)
Lines 137-142 sub authenticate_api_request { Link Here
137
    my $user;
137
    my $user;
138
138
139
    my $spec = $c->match->endpoint->pattern->defaults->{'openapi.op_spec'};
139
    my $spec = $c->match->endpoint->pattern->defaults->{'openapi.op_spec'};
140
141
    $c->stash_embed( $spec );
142
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
- 

Return to bug 24302