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

How to set CLP? #891

Closed
sumihiro opened this Issue Mar 7, 2016 · 8 comments

Comments

Projects
None yet
7 participants
@sumihiro

sumihiro commented Mar 7, 2016

I need to set class level permission to some classes.
I referenced #92, and cheked Schema.js and spec/Schema.spec.js.
Also, set environment PARSE_EXPERIMENTAL_CONFIG_ENABLED=1.

I tried to get config and load schema. But I could not get config.

Parse.Cloud.define('restrict', function(req, res) {
  Parse.Cloud.useMasterKey();

  Parse.Config.get().then((config) => {
    return config.database.loadSchema()
  }).then((schema) => {
    return schema.setPermissions('Product', {
      'find': {}
    });
  }).then((schema) => {
    res.success('OK');
  }, (err) => {
    res.error(err);
  });
});

I got ParseError { code: 105, message: 'config does not exist' } on Parse.Config.get().

How to get config and set CLP?

@gfosco

This comment has been minimized.

Collaborator

gfosco commented Mar 7, 2016

You can get the right config object with:

var Config = require('parse-server/lib/Config');
var config = new Config('your-app-id', '/parse'); // second param is your mount point.
@flovilmart

This comment has been minimized.

Member

flovilmart commented Mar 7, 2016

This config and globalConfig are so confusing :)

@sumihiro

This comment has been minimized.

sumihiro commented Mar 7, 2016

@gfosco Thanks for your advice.
I got config correctly, and set permission successfully!

@sumihiro sumihiro closed this Mar 7, 2016

@chderen

This comment has been minimized.

chderen commented Mar 15, 2016

Hi,
How to set a Role permissions in CLP level?

Thank's

@aaronbkarp

This comment has been minimized.

aaronbkarp commented Mar 15, 2016

It would be extremely useful to have some official documentation/sample code on the recommended way to set CLPs. At the moment I can't get my migrated app to work because it relies heavily on CLPs that I don't know how to migrate.

@bdevore17

This comment has been minimized.

bdevore17 commented Mar 28, 2016

Do CLP's migrate in general, or no?

@chderen

This comment has been minimized.

chderen commented Mar 28, 2016

After search i found the answer how to implement CLP.
The CLP is implemented and can be set via rest api (with master key).
the relevant file in parse-server is Schema.js

example with Parse Js SDK:

Parse._request(
        'PUT',
        'schemas/' + className,
        {className: className, fields: fields, classLevelPermissions: classLevelPermissions}
    )

the value of fields and classLevelPermissions should match the format you get by GET request:

Parse._request(
        'GET',
        'schemas',
        {}
    )

example for CLP

"classLevelPermissions": {
        "find": {
          "FVPW0vrLEB": true
        },
        "get": {
          "FVPW0vrLEB": true
        },
        "create": {},
        "update": {},
        "delete": {
          "*": true
        },
        "addField": {
          "role:isRulsMDfQ": true
        }
      }

i hope it's can helpful.

@drew-gross

This comment has been minimized.

Collaborator

drew-gross commented Mar 28, 2016

The newest version of the Parse Dashboard also lets you set CLPs, as long as you are also on the latest version of Parse Server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment