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

feat: Remove deprecation DEPPS3: Config option enforcePrivateUsers defaults to true #8283

Merged
merged 13 commits into from
Nov 16, 2022
20 changes: 17 additions & 3 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,30 +292,37 @@ describe('ParseGraphQLServer', () => {
let objects = [];

async function prepareData() {
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user1 = new Parse.User();
user1.setUsername('user1');
user1.setPassword('user1');
user1.setEmail('[email protected]');
user1.setACL(acl);
await user1.signUp();

user2 = new Parse.User();
user2.setUsername('user2');
user2.setPassword('user2');
user2.setACL(acl);
await user2.signUp();

user3 = new Parse.User();
user3.setUsername('user3');
user3.setPassword('user3');
user3.setACL(acl);
await user3.signUp();

user4 = new Parse.User();
user4.setUsername('user4');
user4.setPassword('user4');
user4.setACL(acl);
await user4.signUp();

user5 = new Parse.User();
user5.setUsername('user5');
user5.setPassword('user5');
user5.setACL(acl);
await user5.signUp();

const roleACL = new Parse.ACL();
Expand Down Expand Up @@ -7123,6 +7130,7 @@ describe('ParseGraphQLServer', () => {
username: 'user2',
password: 'user2',
someField: 'someValue2',
ACL: { public: { read: true, write: true } },
},
},
someField: 'someValue',
Expand Down Expand Up @@ -7195,6 +7203,7 @@ describe('ParseGraphQLServer', () => {
username: 'user2',
password: 'user2',
someField: 'someValue2',
ACL: { public: { read: true, write: true } },
},
},
},
Expand Down Expand Up @@ -8308,19 +8317,21 @@ describe('ParseGraphQLServer', () => {
const someClass = new Parse.Object('SomeClass');
await someClass.save();

const roleACL = new Parse.ACL();
roleACL.setPublicReadAccess(true);

const user = new Parse.User();
user.set('username', 'username');
user.set('password', 'password');
user.setACL(roleACL);
await user.signUp();

const user2 = new Parse.User();
user2.set('username', 'username2');
user2.set('password', 'password2');
user2.setACL(roleACL);
await user2.signUp();

const roleACL = new Parse.ACL();
roleACL.setPublicReadAccess(true);

const role = new Parse.Role('aRole', roleACL);
await role.save();

Expand Down Expand Up @@ -10597,6 +10608,9 @@ describe('ParseGraphQLServer', () => {
const user = new Parse.User();
user.setUsername('user1');
user.setPassword('user1');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
await user.signUp();

await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear();
Expand Down
3 changes: 3 additions & 0 deletions spec/ParseLiveQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,9 @@ describe('ParseLiveQuery', function () {
user.setUsername('username');
user.setPassword('password');
user.set('foo', 'bar');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);

const query = new Parse.Query(Parse.User);
query.equalTo('foo', 'bar');
Expand Down
6 changes: 6 additions & 0 deletions spec/ParseSession.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
const request = require('../lib/request');

function setupTestUsers() {
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
const user1 = new Parse.User();
const user2 = new Parse.User();
const user3 = new Parse.User();
Expand All @@ -18,6 +20,10 @@ function setupTestUsers() {
user2.set('password', 'password');
user3.set('password', 'password');

user1.setACL(acl);
user2.setACL(acl);
user3.setACL(acl);

return user1
.signUp()
.then(() => {
Expand Down
42 changes: 34 additions & 8 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,13 @@ describe('Parse.User testing', () => {
const ACL = user.getACL();
expect(ACL.getReadAccess(user)).toBe(true);
expect(ACL.getWriteAccess(user)).toBe(true);
expect(ACL.getPublicReadAccess()).toBe(true);
expect(ACL.getPublicReadAccess()).toBe(false);
expect(ACL.getPublicWriteAccess()).toBe(false);
const perms = ACL.permissionsById;
expect(Object.keys(perms).length).toBe(2);
expect(Object.keys(perms).length).toBe(1);
expect(perms[user.id].read).toBe(true);
expect(perms[user.id].write).toBe(true);
expect(perms['*'].read).toBe(true);
expect(perms['*'].write).not.toBe(true);
expect(perms['*']).toBeUndefined();
done();
});

Expand Down Expand Up @@ -875,8 +874,8 @@ describe('Parse.User testing', () => {
kevin.set('password', 'mypass');
await kevin.signUp();
const query = new Parse.Query(Parse.User);
const count = await query.count();
equal(count, 2);
const count = await query.find({ useMasterKey: true });
equal(count.length, 2);
done();
});

Expand Down Expand Up @@ -2153,7 +2152,15 @@ describe('Parse.User testing', () => {
});

it("querying for users doesn't get session tokens", done => {
Parse.User.signUp('finn', 'human', { foo: 'bar' })
const user = new Parse.User();
user.set('username', 'finn');
user.set('password', 'human');
user.set('foo', 'bar');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
user
.signUp()
.then(function () {
return Parse.User.logOut();
})
Expand All @@ -2162,6 +2169,9 @@ describe('Parse.User testing', () => {
user.set('username', 'jake');
user.set('password', 'dog');
user.set('foo', 'baz');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
return user.signUp();
})
.then(function () {
Expand All @@ -2188,7 +2198,14 @@ describe('Parse.User testing', () => {
});

it('querying for users only gets the expected fields', done => {
Parse.User.signUp('finn', 'human', { foo: 'bar' }).then(() => {
const user = new Parse.User();
user.setUsername('finn');
user.setPassword('human');
user.set('foo', 'bar');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
user.signUp().then(() => {
request({
headers: {
'X-Parse-Application-Id': 'test',
Expand Down Expand Up @@ -3426,6 +3443,9 @@ describe('Parse.User testing', () => {
password: 'world',
email: '[email protected]',
});
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);

reconfigureServer({
appName: 'unused',
Expand Down Expand Up @@ -4057,6 +4077,12 @@ describe('Parse.User testing', () => {
silent: true,
});

Parse.Cloud.beforeSave(Parse.User, ({ object }) => {
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
object.setACL(acl);
});

const query = new Parse.Query(Parse.User);
query.doesNotExist('foo');
const subscription = await query.subscribe();
Expand Down
12 changes: 12 additions & 0 deletions spec/ProtectedFields.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('ProtectedFields', function () {
user.setPassword('sekrit');
user.set('email', '[email protected]');
user.set('favoriteColor', 'yellow');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
await user.save();

const fetched = await new Parse.Query(Parse.User).get(user.id);
Expand All @@ -35,6 +38,9 @@ describe('ProtectedFields', function () {
user.set('timeZone', 'America/Los_Angeles');
user.set('favoriteColor', 'yellow');
user.set('favoriteFood', 'pizza');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
await user.save();

const fetched = await new Parse.Query(Parse.User).get(user.id);
Expand All @@ -57,6 +63,9 @@ describe('ProtectedFields', function () {
user.set('timeZone', 'America/Los_Angeles');
user.set('favoriteColor', 'yellow');
user.set('favoriteFood', 'pizza');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
await user.save();

const fetched = await new Parse.Query(Parse.User).get(user.id);
Expand Down Expand Up @@ -108,6 +117,9 @@ describe('ProtectedFields', function () {
user.set('timeZone', 'America/Los_Angeles');
user.set('favoriteColor', 'yellow');
user.set('favoriteFood', 'pizza');
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
user.setACL(acl);
await user.save();

const objA = await new Parse.Object('ClassA').set('foo', 'zzz').set('bar', 'yyy').save();
Expand Down
1 change: 1 addition & 0 deletions spec/RestQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('rest query', () => {
let user = {
username: 'aUsername',
password: 'aPassword',
ACL: { '*': { read: true } },
};
const activity = {
type: 'comment',
Expand Down
4 changes: 3 additions & 1 deletion spec/UserPII.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe('Personally Identifiable Information', () => {
await reconfigureServer();
user = await Parse.User.signUp('tester', 'abc');
user = await Parse.User.logIn(user.get('username'), 'abc');
await user.set('email', EMAIL).set('zip', ZIP).set('ssn', SSN).save();
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
await user.set('email', EMAIL).set('zip', ZIP).set('ssn', SSN).setACL(acl).save();
done();
});

Expand Down
2 changes: 1 addition & 1 deletion spec/ValidationAndPasswordsReset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
'Found. Redirecting to http://localhost:8378/1/apps/verify_email_success.html?username=user'
);
user
.fetch()
.fetch({ useMasterKey: true })
.then(
() => {
expect(user.get('emailVerified')).toEqual(true);
Expand Down
1 change: 0 additions & 1 deletion src/Deprecator/Deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = [
solution:
"Additionally, the environment variable 'PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS' will be deprecated and renamed to 'PARSE_SERVER_DIRECT_ACCESS' in a future version; it is currently possible to use either one.",
},
{ optionKey: 'enforcePrivateUsers', changeNewDefault: 'true' },
{ optionKey: 'allowClientClassCreation', changeNewDefault: 'false' },
{ optionKey: 'allowExpiredAuthDataToken', changeNewDefault: 'false' },
];
2 changes: 1 addition & 1 deletion src/Options/Definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ module.exports.ParseServerOptions = {
env: 'PARSE_SERVER_ENFORCE_PRIVATE_USERS',
help: 'Set to true if new users should be created without public read and write access.',
action: parsers.booleanParser,
default: false,
default: true,
},
expireInactiveSessions: {
env: 'PARSE_SERVER_EXPIRE_INACTIVE_SESSIONS',
Expand Down
2 changes: 1 addition & 1 deletion src/Options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export interface ParseServerOptions {
:DEFAULT: {} */
security: ?SecurityOptions;
/* Set to true if new users should be created without public read and write access.
:DEFAULT: false */
:DEFAULT: true */
enforcePrivateUsers: ?boolean;
/* Allow a user to log in even if the 3rd party authentication token that was used to sign in to their account has expired. If this is set to `false`, then the token will be validated every time the user signs in to their account. This refers to the token that is stored in the `_User.authData` field. Defaults to `true`.
:DEFAULT: true */
Expand Down