REST api with Basic_Auth plugin

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
dcburleigh
Posts: 4
Joined: 28 Nov 2016, 00:14

REST api with Basic_Auth plugin

Post by dcburleigh »

We're using the Basic_Auth plugin, so users are automatically logged in via the Apache authentication.

Mantis 2.25.6
PHP 7.4
Apache 2.4

To use the REST API, however , would require passing both the HTTP auth and the Mantis token
for example

issue_id=1234

curl --header "Authorization: $token" \
--user $user:$pwd \
http://server/mantis/api/rest/issues/$issue_id

but Apache doesn't like mixing --user with the Authorization header.

I tried removing the authentication requirement for the path /mantis/api/rest
but I still get 401 errors.

Is there some Mantis or Apache setup to make this work?
dcburleigh
Posts: 4
Joined: 28 Nov 2016, 00:14

Re: REST api with Basic_Auth plugin

Post by dcburleigh »

I created this file:
DOCROOT/mantis/api/.htaccess
with contents:
Require all granted
This allows me to navigate to the URL https://server/mantis/api without requiring HTTP authentication. So far so good!

However, when I call the REST API, the call fails because it tries to get the user in the Basic_Auth plugin:
<b>Notice</b>: Undefined index: REMOTE_USER in <b>/mantis/plugins/BasicAuth/BasicAuth.php</b> on line <b>39</b><br />
Is there a way for the plugin to detect that it is being called via the REST api, and set the user some other way?
Post Reply