sharepointsharepoint-2013office365-appssharepoint-apps

How to protect SharePoint-List-Contents in SharePoint-hosted Add-In?


I have the following scenario: My Add-In allows to write posts. Any user may "Like" that post. That likes are being saved into a list.

Of course the Add-In needs permission to write that entry into a list. But as (IMHO) I cannot use any elevated privileges inside a SharePoint - hosted Add-In, the user needs to have that permission, right?

So: How can I protect my lists that the user don't just go into the list and modifies the value himself and increases the "likes" for example?

(remark: This is no real-world scenario. I know there are better ways to use a social network-feature. Just wanted to break down my much more complex app)


Solution

  • SharePoint-hosted add-in cannot use App only policy as provider-hosted add-in can to use add-in context with more permissions then user has. SharePoint-hosted add-in is running completely in the context of current user.

    I see 3 possible solutions:

    1. Redesigning the add-in to be provider-hosted)
    2. Implement custom web service and calling this web service from your add-in. That web service can store sensitive information in either custom database or list in app web with customized permissions. But remember that SP admin can modify these permissions.
    3. Store semi-sensitive information into extended properties of item. There's no UI allowing user to manipulate with it but this is not as secure as permission. Advantage of this is that this information is directly connected to the "affected" item and you don't need to afraid of loosing connection between item and like storage. Disadvantage is that extended properties can contain only limited amount of data and user must have permission to update item. You can also use this approach combined with your list.