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 JaResource
could become
plug MyApp.Authenticate when action in [:create, :update, :delete]
plug JaResource.load
plug MyApp.Authorize
plug JaResource.perform
Looking 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.render
Any thoughts on that? Our team would definitely find it useful, but it might be overkill.
In our project, we would like to use
ja_resourcebut 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 byhandle_create/update, call authorisation on that changeset and then either allowja_resourceto 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
could become
Looking at #30, we could split it even further, potentially having something like
Any thoughts on that? Our team would definitely find it useful, but it might be overkill.