-
Notifications
You must be signed in to change notification settings - Fork 33
Description
In our project, we would like to use ja_resource but we're having issues with authorising users. In a lot of cases, the user being authorised to perform an action depends on the changeset they are trying to persist. (For example, an admin can demote another admin, but they should not be allowed to promote them to a higher role). That would mean, that, at some point, we would have to hook into the changeset generated by handle_create/update, call authorisation on that changeset and then either allow ja_resource to continue or halt everything due to lack of proper rights.
The way the whole create process works right now, it doesn't really allow us to put a plug between the loading of resource/creation of changeset and performing of action.
Ideally, we would have something like the option to split up the default ja_resource plug into two of them, so that
plug Authenticate when action in [:create, :update, :delete]
plug JaResourcecould become
plug MyApp.Authenticate when action in [:create, :update, :delete]
plug JaResource.load
plug MyApp.Authorize
plug JaResource.performLooking at #30, we could split it even further, potentially having something like
plug MyApp.Authenticate when action in [:create, :update, :delete]
plug JaResource.load
plug MyApp.Authorize
plug JaResource.perform
plug MyApp.Track
plug JaResource.renderAny thoughts on that? Our team would definitely find it useful, but it might be overkill.