Search code examples
pythonapacheauthenticationhttpsrhel

How to identify the user or machine making an HTTP request to an Apache web server on RHEL 7 using server side Python or client side script?


I have a RHEL 7 Linux server using Apache 2.4 as the httpd daemon. One of the pages served by Apache is a simple https form that is generated using Python 3.11. Currently, the form is submitting and being processed properly, but we have no way to track where the form was submitted from.

Ideally, there would be a field for users to enter their user name, but we have no way of validating if the user name is valid or not.

I would like to add a hidden field to the form that would contain one of the following:

  • User name used to log into the clients computer from where the form was submitted.
  • Computer name of the clients computer from where the form was submitted.
  • IP address of the clients computer from where the from was submitted.

I do not care if this data is discovered by Python while the page is being generated, or by a client side script embedded in the generated web page.

The majority of users will be using Windows 10 and Chrome or Edge as their browser, but there will be Apple and Linux users and other browsers as well.

Is this possible? If so, how?


Solution

  • Would you like every website to have access to your local user- or computer-name, or other local information available to your browser? While there is an aweful lot of information available to webapps, this privacy invasion is not.

    The server will have a record about the sending IP address though, naturally - even without it being part of a form.

    As to the "how": The Python script that processes the submitted form does have access to the request parameters, and with it typically the remote IP address. What you do with it (e.g. save it) is yours. You'll obviously also find the remote IP address in the Apache logs - but there it's disassociated with the actual form submission.