Adding a new user via Admin app, parse-server v6.0.0
New Issue Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
- [x] I can reproduce the issue with the latest version of Parse Server.
Issue Description
After updating parse-server to 6.0.0 I've forced with some problem.
After adding a new user via Admin app, the user is present in database (and in Dashboard) but is absent in Admin app users list. As I can see in Dashboard in ACL column, the new user has an unchecked Public Read option.
To see the user in Admin I have either to set a Public Read option manually in Dashboard or to use setPublicReadAccess() method in afterSave trigger.
Is it correct to use afterSave trigger and setPublicReadAccess() method? Or there are other ways to resole it?
Steps to reproduce
Update parse-server to 6.0.0 version and try to add a new user via Admin app.
Actual Outcome
A new user is absent in Admin app user list.
Expected Outcome
A new user must be present in Admin app user list just after one was created.
Environment
Server
- Parse Server version: 6.0.0
- Operating system: Linux Mint 20.2 Cinnamon and docker
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): localhost
Database
- System (MongoDB or Postgres): MongoDB
- Database version: docker image: mongo:4
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): localhost
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc): JavaScript
- SDK version: "@types/parse": "^2.18.13",
Logs
error: Object not found. {"code":101,"stack":"Error: Object not found.\n at Object.getObject (/parse-server/lib/GraphQL/helpers/objectsQueries.js:54:11)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async getQuery (/parse-server/lib/GraphQL/loaders/parseClassQueries.js:48:10)\n at async resolve (/parse-server/lib/GraphQL/loaders/parseClassQueries.js:76:18)\n at async Promise.all (index 0)\n at async /parse-server/node_modules/@envelop/core/cjs/orchestrator.js:380:27\n at async processRequest (/parse-server/node_modules/@graphql-yoga/common/index.js:178:20)\n at async YogaNodeServer.getResponse (/parse-server/node_modules/@graphql-yoga/common/index.js:881:30)\n at async YogaServer.handleRequest (/parse-server/node_modules/@graphql-yoga/common/index.js:655:30)\n at async YogaNodeServer.handleIncomingMessage (/parse-server/node_modules/@graphql-yoga/node/index.js:174:26)\n at async YogaNodeServer.requestListener (/parse-server/node_modules/@graphql-yoga/node/index.js:144:30)"}
Thanks for opening this issue!
- 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.
What do you mean by "Admin app"?
What do you mean by "Admin app"?
Ok, it doesn't matter - it is our custom app for administration. May be it is unnecessary detail.
But the main question is why on version 6.0.0 a new user after creating has an unchecked Public Read option as default?
Creating users with public read access is not recommended as it exposes a users private information such as email to any other user using the app.
It's extremely easy for anyone to maliciously expose your apps' users simply by calling new Parse.Query(Parse.User).find().
Parse Server version 6 changed this default behaviour by creating users with public read off.
If you need public read for users, it's recommended to make a Profile class and create a one-to-one relation, with the Profile with public read.
For admin app purposes, you could make a cloud function that queries users with masterKey, if the request.user is a given user (ie. admin). Alternatively, you could create a new Admin role and attach your Admin app users to that, and when a user is signed up, set roleReadAccess("Admin", true).
Alternatively, you could set enforcePrivateUsers: false. However, if you are using this feature, I would recommend:
- Adding a
beforeFindconstraint to make sure areq.usercan only query itself - Make sure and objects that use the
_Userobject as a pointer are excluded viabeforeFindorprotectedFields(otherwise a_Usercan be exposed by usinginclude) - Make sure
addFieldpermissions are set tofalsefor all classes, otherwise an attacker could add auserfield and fetch the private object by callinginclude("user") - Make sure
allowClientClassCreationis set tofalse, otherwise an attacker can make a new class and attach pointers
With all these considerations and the risk that exposing Users private information contains, it's much to leave the access control up to Parse Server and leave public read off for all user data.
I'm closing as this is a question around the breaking changes listed in the Parse Server 6.0.0 release, specifically enforcePrivateUsers.
@dblythy Thank you !