Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward client's user-agent instead of Node's #3152

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

alanorth
Copy link
Contributor

References

Description

Forward the client's user-agent instead of Node's. Code by @mark-cooper in #2902 (comment).

Instructions for Reviewers

List of changes in this PR:

  • Adjust forward-client-ip component to also forward the client's user-agent along with the client's IP

Note: there was a small discussion about whether to rename the forward-client-ip component to forward-client-headers and the consensus seemed to be that it was not important for 7.x and 8.x, but maybe we can do that for 9.0.

Include guidance for how to test or review your PR.

To see the client headers you must look in the web server logs, which mean you must run the modified code on a server which has a full set up like Apache HTTPD or Nginx etc. Where before you would see Node.js's user-agent header, you should now see the actual user-agent of the client.

For example, when loading the home page in a web browser, the backend server / API logs used to show:

41.18.204.190 - - [25/Jun/2024:08:55:52 +0200] "GET /server/api HTTP/1.1" 200 7180 "-" "Mozilla/5.0 (Linux x64) node.js/18.17.1 v8/10.2.154.26-node.26"
41.18.204.190 - - [25/Jun/2024:08:55:52 +0200] "GET /server/api/authn/status HTTP/1.1" 200 447 "-" "Mozilla/5.0 (Linux x64) node.js/18.17.1 v8/10.2.154.26-node.26"

With this patch they should show:

41.18.204.190 - - [25/Jun/2024:08:55:55 +0200] "GET /server/api HTTP/1.1" 200 7381 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"        
41.18.204.190 - - [25/Jun/2024:08:55:55 +0200] "GET /server/api/authn/status HTTP/1.1" 200 456 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using yarn lint
  • My PR doesn't introduce circular dependencies (verified via yarn check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

Forward the client's user-agent instead of sending Node's.
@alanorth alanorth added bug 1 APPROVAL pull request only requires a single approval to merge port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release labels Jun 28, 2024
@tdonohue tdonohue added the port to main This PR needs to be ported to `main` branch for the next major release label Jun 28, 2024
Copy link
Contributor

@nwoodward nwoodward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Tested this on a server with Apache and confirmed it works.

@alanorth alanorth merged commit a705067 into DSpace:dspace-7_x Jul 3, 2024
13 checks passed
@alanorth alanorth deleted the client-user-agent branch July 3, 2024 05:54
@dspace-bot
Copy link
Contributor

Successfully created backport PR for main:

@dspace-bot
Copy link
Contributor

Successfully created backport PR for dspace-8_x:

@alanorth alanorth removed port to main This PR needs to be ported to `main` branch for the next major release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release labels Jul 3, 2024
@alanorth alanorth added this to the 7.6.2 milestone Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 APPROVAL pull request only requires a single approval to merge bug
Projects
Development

Successfully merging this pull request may close these issues.

4 participants