You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've heard this requested a couple of times now. Creating an issue so people can discuss details. I'd like to have something like:
{"readOnly": {"propertyName": true}}
We could also make this a setting on the property itself... The version above allows us to implement it outside the scope of properties...
Reacted by Cristian, Laurent De Smet, James Koshigoe, BRAMILLE Sébastien, Alexey Yegupov, Yohanes Gultom, Peter Liapin, Alessandro Maccagnan, Anton Lvovych, Siva Kannan and 10 more
Also very interested in this. My use case is to lock down properties that are used to define relationships so that the relationships can't be changed. For example, an address belongs to a person and is related to it through a personId property. I don't want to allow the address to be assigned to a different user by simply changing the personId value.
If the acting user has write privileges on a given entity, I don't see why wouldn't he be able to update its properties.
If the underlaying database engine had a FK on the field, then the only restricción would be to point to a valid master id. I don't agree on adding model behavior that doesn't map to a native behavior on the database engine. It breaks separation of concerns and introduces an unnecesary coupling between app and db.
Since this restricción doesn't belong to the model itself, it can only exist as a middleware or as a custom rule among the business logic, which in this case would be a remote hook.
In our usecase, all model instances are associated with a Team, and on the basis of this association we derive both access rights as well as relations. This team association is set once when the instance is created, and by spec must never change after that (not even the user who owns the instance is able to change it). The association needs to be exposed via REST, however, since we use it on the client-side to query related data.
Currently we are solving this using mixins, but this almost certainly is a clumsy solution and it would be much more convenient to simply be able to mark the property as immutable.
+1 Would also like to see a readOnly property.
My use case is that we store a number of followers as a property to avoid having to compute it each time from a hasAndBelongsToMany relation wich can be intensive.
But we don't want the user to be able to change the followersCount himself.
I'll be working on a new mixins for this purpose (ETA: TBD) and maybe after some community feedback this could become part of the base code.
Here is the general architecture idea.
First of all I think MSSQL handles this issue beautifully, I'm not reinventing the wheel, so I'll implement something similar.
For any given model, each property will be granted 4 generic permissions by default to all "principals": select, create, edit, delete.
**note: select deny === hidden:["prop"] - should I remove it? This will replicate the same functionality as the "hidden" attribute
The permission check will only be trigger when calling any of the public/remote methods of a model, just like ACL does.
Following the pattern of ACL a propertyLevelPermissions implemented to a model will look something like this:
In the example above I'm denying edit/update permissions to the property "archivedFlag" for all roles and then I'm allowing only users with the "Sys Admin" role to edit/update.
Any thoughts before I get started?
Reacted by Tino Butz, Max Alekseenko, Simon Mitternacht, Baris Aydinoglu, Jackson Vaughan, Nicolás González Parra, Peter Bouda, Alejandro, Julio Bastida and Dan Sterrett
@panlilu and everybody else that likes the idea by @jdhrivas , please use the icon in the top-right corner of his post instead of posting a +1 message.
Posting a +1 message is ambiguous because we don't know if you just like read-only properties in general or the solution posted by the last poster.
Activity
arjan123 commentedon Feb 17, 2015
would be a very handy feature. Maybe in combination with dynamic, calculated properties
mrfelton commentedon Apr 1, 2015
Also very interested in this. My use case is to lock down properties that are used to define relationships so that the relationships can't be changed. For example, an address belongs to a person and is related to it through a personId property. I don't want to allow the address to be assigned to a different user by simply changing the personId value.
violet-day commentedon Apr 1, 2015
+1
mrfelton commentedon May 10, 2015
I've implemented this as a mixin, available at https://www.npmjs.com/package/loopback-ds-readonly-mixin
snapjay commentedon May 30, 2015
Yes, this seems like a huge security issue. I feel like I'm missing something that this can't be done out of the box.
Many thanks @mrfelton. Your mixin works great for now!
bebop23 commentedon Jul 18, 2015
+1
ffflabs commentedon Jul 18, 2015
If the acting user has write privileges on a given entity, I don't see why wouldn't he be able to update its properties.
If the underlaying database engine had a FK on the field, then the only restricción would be to point to a valid master id. I don't agree on adding model behavior that doesn't map to a native behavior on the database engine. It breaks separation of concerns and introduces an unnecesary coupling between app and db.
Since this restricción doesn't belong to the model itself, it can only exist as a middleware or as a custom rule among the business logic, which in this case would be a remote hook.
csvan commentedon Sep 10, 2015
I would very much like this.
In our usecase, all model instances are associated with a Team, and on the basis of this association we derive both access rights as well as relations. This team association is set once when the instance is created, and by spec must never change after that (not even the user who owns the instance is able to change it). The association needs to be exposed via REST, however, since we use it on the client-side to query related data.
Currently we are solving this using mixins, but this almost certainly is a clumsy solution and it would be much more convenient to simply be able to mark the property as immutable.
dotlouis commentedon Nov 3, 2015
+1 Would also like to see a readOnly property.
My use case is that we store a number of followers as a property to avoid having to compute it each time from a hasAndBelongsToMany relation wich can be intensive.
But we don't want the user to be able to change the followersCount himself.
barocsi commentedon Nov 4, 2015
@amenadiel an user would be able to abuse its own profile :)
39 remaining items
Biax2099 commentedon Feb 26, 2017
+1
timlind commentedon Mar 28, 2017
This feature should be based on ACL roles, i.e only admin can edit this property, or only team owner can rename team
aaronbuchanan commentedon Mar 28, 2017
+1
ishaaqj commentedon Mar 30, 2017
+1
jdhrivas commentedon Mar 30, 2017
I'll be working on a new mixins for this purpose (ETA: TBD) and maybe after some community feedback this could become part of the base code.
Here is the general architecture idea.
**note: select deny === hidden:["prop"] - should I remove it? This will replicate the same functionality as the "hidden" attribute
In the example above I'm denying edit/update permissions to the property "archivedFlag" for all roles and then I'm allowing only users with the "Sys Admin" role to edit/update.
Any thoughts before I get started?
panlilu commentedon May 4, 2017
+1
christiaanwesterbeek commentedon May 4, 2017
@panlilu and everybody else that likes the idea by @jdhrivas , please use the
icon in the top-right corner of his post instead of posting a +1 message.
Posting a +1 message is ambiguous because we don't know if you just like read-only properties in general or the solution posted by the last poster.
kjdelisle commentedon Aug 15, 2017
https://github.com/fullcube/loopback-ds-readonly-mixin exists as a workaround for this requirement. We're winding down feature development of loopback@3.x in favour of loopback-next. Closing.