glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.24k stars 1.29k forks source link

UserId override for ITIL Solution through API #8090

Closed bosquig closed 3 years ago

bosquig commented 4 years ago

Describe the bug

When adding a solution to a ticket through the API with a given "users_id", the input "users_id" is overriden by the current user which is a problem if we have a connector user handling API requests. Can you be consistant with the followup behavior for example ?

in itilsolution.class.php - prepareInputForAdd : $input['users_id'] = Session::getLoginUserID();

whereas in itilfollowup.class.php - prepareInputForAdd :

 if (!isset($input["users_id"])) {
         $input["users_id"] = 0;
         if ($uid = Session::getLoginUserID()) {
            $input["users_id"] = $uid;
         }
      }

To reproduce

POST /apirest.php/ITILSolution {"input":[{"content":"resolution","users_id":6,"itemtype":"Ticket","_auto_import":true,"items_id":2,"solutiontypes_id": 1,"add":true}]}

Expected behavior

If users_id of the request session is "1", the solution will be linked to users_id 1 instead of 6. (should be the user indicated in POST body and not current user)

Your GLPI setup (you can find it in Setup > General menu, System tab)

GLPI 9.5.1
jeanpaulo commented 4 years ago

Same happened to me yesterday, on GLPI 9.4.5, through another endpoint.

To reproduce: POST /apirest.php/ticket//itilsolution/ {"id":14163,"input":[{"itemtype":"Ticket","items_id":14163,"content":"Content.","users_id":95,"status":2,"solutiontypes_id":0}]}

When I get this itil solution request, the users_id is different. The API posted the integration user that i was testing.

github-actions[bot] commented 3 years ago

There has been no activity on this issue for some time and therefore it is considered stale and will be closed automatically in 10 days.

If this issue is related to a bug, please try to reproduce on latest release. If the problem persist, feel free to add a comment to revive this issue. If it is related to a new feature, please open a topic to discuss with community about this enhancement on suggestion website.

You may also consider taking a subscription to get professionnal support or contact GLPI editor team directly.