served by a url:
url(r'^job-offers/', LDPViewSet.urls(model=JobOffer, nested_fields=["skills"])),
In the INSTALLED_APPS, I have included:
'oidc_provider', 'guardian',
And I have the authentication activated:
AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend', 'guardian.backends.ObjectPermissionBackend']
I created 2 job offers and 1 users with all permissions on one job offer, but not the other.
When I go on http://localhost:8000/job-offers/ logged in as my user, I can see both job offers, even the one on which I can see I have no permissions.
I should only see the objects on which I have permissions.
The view is throwing errors from user of super() (with no arguments) - so it turns out this is python 3 only code.
I can make it python 2 compatible (a lot of linux systems come with 2.x installed - or did as of last year )
so i installed a virtualenv under python3
only to finf django 1.11 doesnt work with python 3.7
so installed a new virtualenv with python3.6
finally got it running again...
currently up to this - need to configure more stuff
=>
....
Exception Type: ImproperlyConfigured at /job-offers/
Exception Value: Could not resolve URL for hyperlinked relationship using view name "member-detail". You may have failed to include the related model in your API, or incorrectly configured the lookup_field attribute on this field.
By Rob on 2018-10-19T07:12:59 (imported from GitLab project)
Oh yes sorry I realized yesterday that Django 1.11 wasn't compatible with python 3.7.
We'll have to stick to Python 3.6.
The error you get is because you include in your object representation a link to a member. As it has to be represented in json-ld, it needs to be represented as a url. So Django Rest Framework requires a url in urls.py. You can either exclude the member from your object representation (exclude=['member'] in the url line) or add a new url line with members (url(r'^members/', LDPViewSet.urls(model=Member)),).
OK I have read as much as i can find on this, and I think we have three interacting issues here:
We should not need to set model permissions for users to use object permissions - so a conceptual challenge
following on from this, access to individual objects works only if model permissions also set
lists ignore object permissions in DRF - and if we set model permissions then object permissions are overridden - the recommended way of filtering lists doesnt work (model permissions are more permissive)
fix proposed - please test and verify - if it still requires model level permissions however, which I remain unconvinced about - and if truly necessary then this ought to be automated rather than an extra manual step to set up.
By Rob on 2018-10-22T23:19:47 (imported from GitLab project)
Thanks, it looks good!
I agree that this system is not ideal, but that solves the pain point we
have in the short run. We'll keep setting the user's model permissions for
now, and we'll look for a solution later.
How do you feel about this project so far? Are you up for the next
challenge?