glpi-project / glpi-inventory-plugin

GLPI Inventory plugin
GNU Affero General Public License v3.0
43 stars 24 forks source link

Collect : access denied on POST when using a proxy #495

Closed JulienRemi closed 2 months ago

JulienRemi commented 2 months ago

Describe the bug

Collect task throw an error on the POST request when a proxy is used by the agent, because it receive an html Access Refused page :

[Thu Apr  4 16:17:52 2024][debug2] [http client] POST: action=setAnswer&_sid=7&_cpt=1&uuid=660eb484740a3&tag=XXXXXX
[Thu Apr  4 16:17:52 2024][debug] [http client] Using 'http://111.111.111.111:1111' as proxy for http protocol
[Thu Apr  4 16:17:52 2024][error] [http client] Can't decode JSON content, starting with:
<!DOCTYPE html>
<html lang="fr"       >
<head>
   <title>Accès refusé - GLPI</title>

   <meta charset="utf-8" />

      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
...

There is an error in the access-error.log file on the server :
CSRF check failed for User ID: at /plugins/glpiinventory/b/collect/?action=setAnswer&uuid=660eb484740a3&method=POST

It only append when using a proxy.

To reproduce

  1. Setup the glipiinventory-agent config with a proxy.
  2. Create a collect task for that computer
  3. Run the agent

Expected behavior

Collect task working like it does without proxy

Operating system

Windows

GLPI Agent version

Other (See additional context below)

GLPI version

10.0.12

GLPIInventory plugin

1.3.5

Additional context

Agent version : 1.7.1

trasher commented 2 months ago

This sounds like a configuration issue rather than a bug. Probably not related, but you should also consider upgrading GLPI to the latest stable version.

JulienRemi commented 2 months ago

Ho yes sorry I will put it on the forum.

JulienRemi commented 2 months ago

Hi,
I found that the agent doesn't put cookies informations when a proxy is set in the GLPI-agent configuration.

Here is the request when no proxy is set up :
image

And with a proxy :
image

I received the Set-cookie header in both case.

Could the access denied come from that ?

JulienRemi commented 2 months ago

Hi, do I need to recreate a new issue or this one can be reopened ?

stonebuzz commented 2 months ago

Hi @JulienRemi

As a result, you need to open an issue on the agent repo and not on the plugin repo.

https://github.com/glpi-project/glpi-agent