- def name_link_owner_is_tail
- if link_class == 'name'
- self.owner_uuid = tail_uuid
- ensure_owner_uuid_is_permitted
+ # A user is permitted to create, update or modify a permission link
+ # if and only if they have "manage" permission on the object
+ # indicated by the permission link's head_uuid.
+ #
+ # All other links are treated as regular ArvadosModel objects.
+ #
+ def ensure_owner_uuid_is_permitted
+ if link_class == 'permission'
+ ob = ArvadosModel.find_by_uuid(head_uuid)
+ raise PermissionDeniedError unless current_user.can?(manage: ob)
+ # All permission links should be owned by the system user.
+ self.owner_uuid = system_user_uuid
+ return true
+ else
+ super