Skip to content
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

paramsFromClient pollutes context by default #730

Open
FossPrime opened this issue Aug 30, 2023 · 0 comments
Open

paramsFromClient pollutes context by default #730

FossPrime opened this issue Aug 30, 2023 · 0 comments

Comments

@FossPrime
Copy link
Contributor

FossPrime commented Aug 30, 2023

delete params.query.$client;

While whitelisting is a good security feature, it is the adapter's job to complain about invalid query parameters, not ours.

It makes it difficult to compose hooks with this as it damages the context if used at app level/around/provider and also in services.

Proposal:

   const foreignParamCount = 0
    // in an Object.keys(ctx.params.query?.$client) loop, foreignParamCount++
	if (foreignParamCount === 0) {
      delete ctx.params.query.$client
    }

The alternative is to dump repetitive code like this in all over userland hooks:

delete ctx.params.query.$client.sudo
if (Object.keys(ctx.params.query.$client).length === 0) {
  delete ctx.params.query.$client
}
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

No branches or pull requests

1 participant