Skip to content

Is there any way to edit Class Level Permissions Programatically? #5888

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
stevestencil opened this issue Aug 5, 2019 · 11 comments
Closed
Labels
type:feature New feature or improvement of existing feature

Comments

@stevestencil
Copy link
Contributor

With the latest version of parse we can now have a class level permission set for the "count" operation. This makes it so that all class level permissions have to be updated to support this operation, otherwise you'll get permission errors when calling "count". I know we can do this via the dashboard but if other devs are working in the same project they'll have to update the same permissions on their local instance, dev instances, staging instances, etc. Ideally I could update the class level permissions programmatically once parse starts so that any other devs working on the project won't have to worry.

Is there any way to edit the class level permissions through the API?

@Moumouls
Copy link
Member

Moumouls commented Aug 5, 2019

I think you can do this with the REST API:
Rest Guide CLP

// POST http://my-parse-server.com/schemas/Announcement
// Set the X-Parse-Application-Id and X-Parse-Master-Key header
// body:
{
  classLevelPermissions:
  {
    "find": {
      "requiresAuthentication": true,
      "role:admin": true
    },
    "get": {
      "requiresAuthentication": true,
      "role:admin": true
    },
    "create": { "role:admin": true },
    "update": { "role:admin": true },
    "delete": { "role:admin": true }
  }
}

@stevestencil
Copy link
Contributor Author

this is exactly what I need... Thank you!

@dplewis
Copy link
Member

dplewis commented Aug 5, 2019

@stevestencil This has been discussed adding to the JS SDK CLP needs an API. Would like to get started on this?

@stevestencil
Copy link
Contributor Author

I would be happy to add this... this would be my first time so I will need some guidance... I'd imagine i'll be adding it to the ParseSchema.js file?

@davimacedo
Copy link
Member

Yes. It should be added in the ParseSchema.js file of the JS SDK.

@unmec
Copy link

unmec commented Aug 8, 2019

Just a few notes:

  • classLevelPermissions in req body should be double quoted otherwise Parse will complain about JSON format

  • If I run this command on an existing Class, Parse will return 400 saying that Class exist already and unable to change CLP. However creating a new Class is fine

@davimacedo
Copy link
Member

You can actually add and remove fields of an existing class. But you can't change an existing field of an existing class.

@unmec
Copy link

unmec commented Aug 9, 2019

@davimacedo Very helpful as this is not explicitly stated in doc, thanks!

Modifying the schema
You can add or delete columns to a schema

@unmec
Copy link

unmec commented Aug 16, 2019

Um, just want to add that the docs are clear actually with an example of PUT command that I didn't catch earlier. ;-)

@stale
Copy link

stale bot commented Sep 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 30, 2019
@stale stale bot closed this as completed Oct 7, 2019
@davimacedo davimacedo reopened this Oct 8, 2019
@stale stale bot removed the wontfix label Oct 8, 2019
@dplewis dplewis added enhancement type:feature New feature or improvement of existing feature labels Oct 15, 2019
@dplewis
Copy link
Member

dplewis commented Oct 16, 2019

Closing via parse-community/Parse-SDK-JS#960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

No branches or pull requests

6 participants