Skip to content

ID length is hardcoded (10 chars) for CLP validation #6331

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

Closed
BufferUnderflower opened this issue Jan 10, 2020 · 0 comments · Fixed by #6332
Closed

ID length is hardcoded (10 chars) for CLP validation #6331

BufferUnderflower opened this issue Jan 10, 2020 · 0 comments · Fixed by #6332

Comments

@BufferUnderflower
Copy link
Contributor

BufferUnderflower commented Jan 10, 2020

Issue Description

  1. By default objectIdSize is set to 10. It can be configured to any fixed length - see Add config for objectId size #3950.
  2. There is a recent addition allowing to set custom object ids #6101 Let users define objectId #6177.

During CLP validation there is a regEx allowing exactly 10 chars:

const userIdRegex = /^[a-zA-Z0-9]{10}$/;

This leads to a problem: if you decide to change objectIdSize:
CLP for user with id.length != 10 won't be accepted by schema controller.
Same for custom ids.

Steps to reproduce

  1. Launch server with objectIdSize: 11
   it('should aceept class-level permission for custom userid of any length', async done => {
    await global.reconfigureServer({
      customIdSize: 11,
    });

    const id = 'e1evenChars';

    const { data } = await request({
      method: 'POST',
      url: 'http://localhost:8378/1/schemas/AClass',
      headers: masterKeyHeaders,
      json: true,
      body: {
        classLevelPermissions: {
          find: {
            [id]: true,
          },
        },
      },
    });

    expect(data.classLevelPermissions.find[id]).toBe(true);

    done();
  });

Expected Results

schema is accepted

Actual Outcome

'e1evenChars' is not a valid key for class level permissions

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 3.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant