-
Notifications
You must be signed in to change notification settings - Fork 89
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
add $client hook #65
add $client hook #65
Conversation
- It will help people feel safe and warm inside, instead of wondering if they’re doing something that’s a hack. - Will put docs in GitBook once this is merged.
@@ -225,3 +225,49 @@ export const isNot = (predicate) => { | |||
return result.then(result1 => !result1); | |||
}; | |||
}; | |||
|
|||
/** | |||
* Move params from client to hook.params. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$client
}; | ||
}; | ||
|
||
const reservedParamProps = ['app', 'authenticated', '__authenticated', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should sequelize and mongoose be in this list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any other adapters have special props? Knex? Stripe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I don't think so but I'd have to look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
permitted
and __permitted
have now been removed. The permissions hooks no longer use those fields based on this discussion feathersjs-ecosystem/feathers-permissions#4 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its hook.app
not hook.params.app
. So app
should be removed.
assert.throws(() => { | ||
$client( | ||
'app', 'authenticated', '__authenticated', | ||
'permitted', '__permitted', 'provider', 'query' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just forgot to remove permitted
and __permitted
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that catch!
I'm not sure about We might be able to define things like |
Yeah that's the plan but until I get that sorted the whitelist for that piece is a good prevention measure. So we can either hold up this hook or ship it and pull that stuff out in the future.
I agree but then we should probably rename those in the adapters to |
you have the wrong Marshall :) |
Poor @marshall, pretty sure that has happened a couple times on some of our issues/PRs. Sorry about that mate! 😄 @eddyystop I think you meant @marshallswain |
It's not implicit thought right? You have to explicitly whitelist a property. So if you explicitly whitelist something potentially dangerous there isn't much we can do about it so why try and do it with (some of) the stuff we know about right now? Oh also, we probably want a reverse of this hook for the client side (so something that puts a whitelist of params into |
@daffl, your first comment is valid. I think another point of the whitelist was for the server to limit what the client may specify. It prevents what someone hacking from the browser console can do. How will we package client side hooks? We'd also need a copy of them in this repo so the server can do what the client can. Merry Christmas eve. |
Probably fairly simple like: function client(... whitelist) {
return function(hook) {
const client = hook.params.query.$client = {};
whitelist.forEach(key => client[key] = hook.params[key]);
}
} |
I add the client-side hook as a separate PR |
I still don't think that the |
ok 2 comments:
After that is done |
Looks good. @eddyystop! |
instead of wondering if they’re doing something that’s a hack.