|
Lines 91-96
sub authenticate_api_request {
Link Here
|
| 91 |
) if $cookie and $action_spec->{'x-koha-authorization'}; |
91 |
) if $cookie and $action_spec->{'x-koha-authorization'}; |
| 92 |
} |
92 |
} |
| 93 |
|
93 |
|
|
|
94 |
# Check for malformed query parameters |
| 95 |
my @errors; |
| 96 |
my %valid_parameters = map { $_->{name} => 1 if $_->{in} eq 'query' } @{$action_spec->{parameters}}; |
| 97 |
my $existing_params = $c->req->query_params->to_hash; |
| 98 |
for my $param ( keys %{$existing_params} ) { |
| 99 |
push @errors, { path => "/query/".$param, message => 'Malformed query string' } unless exists $valid_parameters{$param}; |
| 100 |
} |
| 101 |
return $c->render_swagger({},\@errors,400) if @errors; |
| 102 |
|
| 94 |
return $next->($c) unless $action_spec->{'x-koha-authorization'}; |
103 |
return $next->($c) unless $action_spec->{'x-koha-authorization'}; |
| 95 |
unless ($user) { |
104 |
unless ($user) { |
| 96 |
return $c->render_swagger({ error => "Authentication required." },{},401); |
105 |
return $c->render_swagger({ error => "Authentication required." },{},401); |
| 97 |
- |
|
|