Coder Social home page Coder Social logo

Comments (3)

tjwebb avatar tjwebb commented on August 15, 2024

@ryanwilliamquinn I wonder if this can flow also into the Transitive Permissions feature (#64). Basically, we currently avoid this problem by setting populate: false. But sails allows you to complexly query for associations and whatnot, and we'll want all these permissions checks to apply to those relations as well

from sails-permissions.

bsill avatar bsill commented on August 15, 2024

Here is the problem I am running into, and am wondering if it relates to this issue:

I have a model, DataSource, which has a one-to-many with Schema, as follows:

...

attributes: {
    label  : { type: 'string', required : true, maxLength : 30 },
    produces : {
        collection : 'schema',
        via : 'producedBy'
    }
}

...

I have blueprint populate set to false, such that when I load DataSources, I do not also receive the schemas it produces by default. Thus I need to make a call for them on demand. I am doing so via the following blueprint action:

/dataSource/:id/produces

Unfortunately, I am receiving a 404 response, as the CriteriaPolicy is trying to apply the criteria for DataSources to the data which is returned, which is an array of Schema models, not DataSources. Thus, we hit this conditional case in CriteriaPolicy.responsePolicy, and return 404:

if (permitted.length === 0) {
    sails.log.info('permitted.length === 0');
    return res.send(404);
}

Looks like ModelPolicy may need to be made smarter to identify the blueprint url pattern /model/:id/association, and set the model class to the association's class, not the root model.

Do you plan to make this enhancement? I use the on-demand association request a number of places.

Thanks

from sails-permissions.

pixelbacon avatar pixelbacon commented on August 15, 2024

This is a rather large bug IMO; a main reason many people use Sails is because of the blueprint & association portion of the API...

Any update on this?

from sails-permissions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.