@@ -, +, @@ It should return a 403 error, with an error message "Authentication failure". terminal you started it This time it should return a 400 error with an error message saying the "grant_type" property is missing. This error is normal as we did not send any data in the POST request body, and seeing this means Koha allowed us to use that route because it recognized '/api/v1/oauth/' at the start of the URL path --- Koha/App/Intranet.pm | 6 ------ Koha/App/Opac.pm | 6 ------ Koha/App/Plugin/RESTV1.pm | 3 ++- Koha/REST/V1.pm | 4 +++- 4 files changed, 5 insertions(+), 14 deletions(-) --- a/Koha/App/Intranet.pm +++ a/Koha/App/Intranet.pm @@ -35,7 +35,6 @@ sub startup { $self->plugin('CGIBinKoha'); # Create routes for API - # FIXME This generates routes like this: /api/api/v1/... $self->plugin('RESTV1'); $self->hook(before_dispatch => \&_before_dispatch); @@ -54,11 +53,6 @@ sub _before_dispatch { # Remove Koha version from URL $path =~ s/_\d{2}\.\d{7}\.(js|css)/.$1/; - # See FIXME above - if ($path =~ m|^/api/v|) { - $path = '/api' . $path; - } - $c->req->url->path->parse($path); } --- a/Koha/App/Opac.pm +++ a/Koha/App/Opac.pm @@ -35,7 +35,6 @@ sub startup { $self->plugin('CGIBinKoha', opac => 1); # Create routes for API - # FIXME This generates routes like this: /api/api/v1/... $self->plugin('RESTV1'); $self->hook(before_dispatch => \&_before_dispatch); @@ -54,11 +53,6 @@ sub _before_dispatch { # Remove Koha version from URL $path =~ s/_\d{2}\.\d{7}\.(js|css)/.$1/; - # See FIXME above - if ($path =~ m|^/api/v|) { - $path = '/api' . $path; - } - $c->req->url->path->parse($path); } --- a/Koha/App/Plugin/RESTV1.pm +++ a/Koha/App/Plugin/RESTV1.pm @@ -26,7 +26,8 @@ use Koha::REST::V1; sub register { my ($self, $app) = @_; - $app->routes->any('/api')->partial(1)->to(app => Koha::REST::V1->new); + my $v1 = Koha::REST::V1->new(config => { route => '/v1' }); + $app->routes->any('/api')->partial(1)->to(app => $v1); } 1; --- a/Koha/REST/V1.pm +++ a/Koha/REST/V1.pm @@ -98,10 +98,12 @@ sub startup { } ) unless C4::Context->needs_install; # load only if Koha is installed + my $route = $self->config('route') // '/api/v1'; + $self->plugin( OpenAPI => { spec => $spec, - route => $self->routes->under('/api/v1')->to('Auth#under'), + route => $self->routes->under($route)->to('Auth#under'), } ); --