I am implementing a collaborative web gallery, and I have a few roles for each user:
- Admin
- DeleteImage
- DeleteOwnImage
- etc..
For any controller-action, we can apply [Authorize] tag to them plus which roles we want to allow, right? It is fine for Admin/DeleteImage since these two are global; but my question is, like DeleteOwnImage is kind of contextual, in order to determine whether it is valid, we need:
- To know what image it is trying to delete (from request)
- Retrieve the owner of that image (from service or repository)
- Compare current user = that owner
Obviously [Authorize] is not enough to do so, but is it possible to do that on custom ActionFilters? Any hint?