I am working on a project that uses django-rules to apply some permissions checks using custom predicates. This particular project I am working on is using Django asynchronously via Daphne. I have found that, if I use something like:
perm_check = await sync_to_async(user.has_perm)(MyModel.get_perm("change"), my_object)
Everything works okay. However, if I use the new ahas_perm variant (introduced in Django 5.2), like so:
perm_check = await user.ahas_perm(MyModel.get_perm("change"), my_object)
Then my custom predicates are all skipped. I suspect this has to do with there being no ahas_perm implementation in the ObjectPermissionBackend (here), so Django sees the backend has no implementation and it is skipped. I think it would be good to have an implementation for ahas_perm in the backend, so that the ahas_perm interface can be used just as easily as has_perm.
I am open to contributing at least a simple implementation, if this was not already planned/in-work.
I am working on a project that uses
django-rulesto apply some permissions checks using custom predicates. This particular project I am working on is using Django asynchronously via Daphne. I have found that, if I use something like:Everything works okay. However, if I use the new
ahas_permvariant (introduced in Django 5.2), like so:Then my custom predicates are all skipped. I suspect this has to do with there being no
ahas_permimplementation in theObjectPermissionBackend(here), so Django sees the backend has no implementation and it is skipped. I think it would be good to have an implementation forahas_permin the backend, so that theahas_perminterface can be used just as easily ashas_perm.I am open to contributing at least a simple implementation, if this was not already planned/in-work.