<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 14, 2020 at 4:37 AM Matthias Dellweg <<a href="mailto:mdellweg@redhat.com">mdellweg@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I think, it would help me to understand if you could reiterate what<br>
kind of policy this model holds. Is it the class level permission like<br>
"Only admins can create new repositories."?<br></blockquote><div>It holds a database equivalent of this policy for example:  <a href="https://github.com/pulp/pulp_file/compare/master...bmbouter:rbac-PoC#diff-b8a33258feb0183716da827efd0b4102R19-R54">https://github.com/pulp/pulp_file/compare/master...bmbouter:rbac-PoC#diff-b8a33258feb0183716da827efd0b4102R19-R54</a></div><div>These would be loaded 100% from the DB and no longer in code. This is more or less recommended by drf-access-policy here <a href="https://rsinger86.github.io/drf-access-policy/loading_external_source/">https://rsinger86.github.io/drf-access-policy/loading_external_source/</a></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
What kind of context does a lookup for these objects? Is it the<br>
PermissionClass that carries a context containing an instance to the<br>
view / viewset, or the request with the resolver_match?<br></blockquote><div>It only holds the policy, the context data is available on the request and in the task, so only the "statements" live in the db.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
If it is userfacing i would probably also go for option 1 with the hrefs.<br>
<br>
On Tue, Jul 14, 2020 at 2:21 AM Dennis Kliban <<a href="mailto:dkliban@redhat.com" target="_blank">dkliban@redhat.com</a>> wrote:<br>
><br>
> Pulp 2 users would definitely be familiar with describing policies in terms of urls. The Pulp 3 REST API already uses the pulp_href field as the primary identifier. You should implement idea 1.<br>
><br>
> On Mon, Jul 13, 2020, 5:45 PM Brian Bouterse <<a href="mailto:bmbouter@redhat.com" target="_blank">bmbouter@redhat.com</a>> wrote:<br>
>><br>
>> I need some design input. To store AccessPolicy data in the DB I think we want one Model where each instance is the access policy for a given viewset. I think this would be better than one Model per Viewset which would generate N tables for N viewsets with 1 instance of each which would be very strange and inefficient.<br>
>><br>
>> So let's assume we have a simple definition like the one below. Each instance stores the policy for one viewset.<br>
>><br>
>> class AccessPolicy(BaseModel):<br>
>>     data = JSONField()<br>
>><br>
>> So what second field can I add to this that would allow me to relate an instance of this model to a viewset. For example the FileRemoteViewset here: <a href="https://github.com/pulp/pulp_file/blob/de638519fc02d588f403db4c5cfcca7552543c50/pulp_file/app/viewsets.py#L116" rel="noreferrer" target="_blank">https://github.com/pulp/pulp_file/blob/de638519fc02d588f403db4c5cfcca7552543c50/pulp_file/app/viewsets.py#L116</a><br>
>><br>
>> Idea 1: Add a viewset = CharField(). Have it store values as URLs, e.g. /pulp/api/v3/remotes/file/file/.<br>
>> Idea 2: Add a viewset = CharField(), and have it store values as classpaths, e.g. 'pulp_file.app.viewsets.RemoteFileViewset'.<br>
>><br>
>> I think Idea 1 makes the most sense because that's how our users think of it. I can't think of a good alternative. What do you think makes the most sense? What alternative ideas should we consider?<br>
>><br>
>> If you have feedback please share it. I need to start into something to get it going tomorrow even if it's just Idea 1 for lack of an alternate proposal.<br>
>><br>
>> Thanks,<br>
>> Brian<br>
>> _______________________________________________<br>
>> Pulp-dev mailing list<br>
>> <a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
>> <a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
><br>
> _______________________________________________<br>
> Pulp-dev mailing list<br>
> <a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
> <a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
<br>
</blockquote></div></div>