I have my extended user model in the Meteor.users
collection, which I'm publishing most fields from to the client. Each user has an isAdmin
field, set to false
by default.
Now I have two concerns, which are linked:
How to make sure, components meant for admins can only be rendered, if the
isAdmin
field in theMeteor.users
collection is set totrue
?How to make sure, the
isAdmin
field on theMeteor.users
collection cannot be modified from the clients console?
Concerning 1.
I'm hesitant to publish this field to the client and simply evaluate isAdmin
on the client side.
I'm not sure if there is some hackish way through the console to simply change isAdmin
in a way that would allow to render the component (or part of it) that is only meant for admins on the client. I could imagine that it is possible with Object.defineProperty()
to do so, for example.
Should I use
server-side rendering
to secure the admin part of my UI?
Concerning 2.
Consider the first paragraph on Profile editing in this article about common mistakes. It suggests that isAdmin
could easily be changed from the client by calling Meteor.users.update(Meteor.userId(), {$set: {'isAdmin': true}})
from the console.
When I run it, being logged in to my application, I get update failed: Access denied
though.
But even the official documentation still suggests to add
// Deny all client-side updates on the Lists collection
Lists.deny({
insert() { return true; },
update() { return true; },
remove() { return true; },
});
at https://guide.meteor.com/security.html#allow-deny
There is an answer, suggesting that it's enough to simply check for the isAdmin
property on the server side, if you make sure that the Meteor.methods
are server-only. But it doesn't talk about allow-deny
at all and it's 6 years old.
Can anyone tell, what truly is the case as of today?