Skip to content

Suggestion: Have whitelist_client and whitelist_server instead of whitelist #2550

Closed

Description

@awhig

I'm new to feathers, so my suggestion may be the same as #2445

Please close this request if this is the case.

I need to use $populate on the server. I do not want to allow the client to send a query using $populate.

As it is, I need to whitelist $populate in the service so I can use it on the server. This also allows the client to send a query with $populate.

Extra coding has to be done to ensure the client does not send a $populate parameter. I would like to easily not allow the client to use $populate, but still use it on the server.

Activity

  1. BenZed commented on Mar 18, 2022

    @BenZed

    Check that there is a provider before eliminating the query param.

  2. DaddyWarbucks commented on Apr 6, 2022

    @DaddyWarbucks
    Member

    I actually stumbled up this issue as I was checking if there was already an issue regard what I was about to post. Similar to whitelist supporting multiple providers, it would also be nice if multi did as well. I would like to allow multi on the server but not on the client. Perhaps a better syntax would be

    // Keep the old config for backwards compatibility. If the user
    // passes options like this then the whitelist/multi applies to all providers
    const options = {
      whitelist: ['$and'],
      multi: true
    }
    
    // Also allow this
    const options = {
      whitelist: {
        server: [...] // bummer, server is actually provider: undefined,
        rest: [...],
        socketio: [...]
      },
      multi:{
        server: true,
        rest: false
        socketio: false
      }
    }

    I know this can be done in hooks (and that may be better place), but this is kind of a wishlist item I guess. I will also open an issue in feathers-hooks-common to add some hooks around these two items.

  3. daffl commented on Apr 25, 2022

    @daffl
    Member

    I'm inclined to update #2607 with adding double underscore (not super great naming but I can't think of anything better) hook-less service methods that don't do any sanitizing or validation. So basically you'd have:

    • _find, _create etc. which validates queries, filters and multi checks and passes the sanitized data to __find, __create etc.
    • __find, __create which just takes whatever you pass and rolls with it

    The reason why all sanitizing is now done in the single-underscored service methods is described in more detail in #2605. Basically I'd like people to be able to extend from the adapters and then implement the actual service methods with whatever types they want (usually just calling the _method in turn).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions