parse-community / parse-community/parse-server

No IP address in request when `directAccess: true`

Open
#8,806 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

New Issue Checklist
Issue Description

When setting the Parse Server option directAccess: true, the request object in triggers have no IP address set.

This could be considered a characteristic of the direct access feature, but there are a few test cases that expect the IP address to be set, so it should probably be considered a bug.

https://github.com/parse-community/parse-server/blob/4b3ce20300b05b015b48efeb82d693200159911f/spec/CloudCode.spec.js#L2006-L2015

https://github.com/parse-community/parse-server/blob/4b3ce20300b05b015b48efeb82d693200159911f/spec/CloudCode.spec.js#L2083-L2091

https://github.com/parse-community/parse-server/blob/4b3ce20300b05b015b48efeb82d693200159911f/spec/CloudCode.spec.js#L2468-L2483

All these tests pass, only because the test suite does not actually use the ParseServerRESTController because the test helper always sets the normal REST controller:

https://github.com/parse-community/parse-server/blob/4b3ce20300b05b015b48efeb82d693200159911f/spec/helper.js#L169

See https://github.com/parse-community/parse-server/issues/8808 for context about this override.

Steps to reproduce
  1. Set Parse Server option directAccess: true.
  2. Save a Parse.User.
  3. The request object in Parse.Cloud.beforeSave('_User', async request => { ... }); has the property request.ip set to undefined.
Actual Outcome

request.ip set to undefined

Expected Outcome

request.ip set to localhost, e.g. 127.0.0.1 in IPv4 environments or ::1 in IPv6 environments.

Possibly just set the IP with a simple:

function getLoopbackAddress() {
  const isIPv6Supported = os.networkInterfaces().lo0?.some(iface => iface.family === 'IPv6');
  return isIPv6Supported ? '::1' : '127.0.0.1';
}
Environment

Server

  • Parse Server version: 6.3.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/ParseServerRESTController.js and the controller override in spec/helper.js, then inspect the referenced cases in spec/CloudCode.spec.js. Run the direct-access trigger tests and verify that request.ip is populated with the expected loopback address rather than undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.