<div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 20, 2018 at 3:50 PM Matt Riedemann <<a href="mailto:mriedemos@gmail.com">mriedemos@gmail.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">On 12/20/2018 1:45 PM, Lance Bragstad wrote:<br>
> <br>
> One way you might be able to do this is by shoveling off the policy <br>
> check using oslo.policy's http_check functionality [0]. But, it still <br>
> doesn't fix the problem that users have roles on projects, and that's <br>
> the standard for relaying information from keystone to services today.<br>
> <br>
> Hypothetically, the external policy system *could* be an API that allows <br>
> operators to associate users to different policies that are more <br>
> granular than what OpenStack offers today (I could POST to this policy <br>
> system that a specific user can do everything but resize up this <br>
> *specific* instance). When nova parses a policy check, it hands control <br>
> to oslo.policy, which shuffles it off to this external system for <br>
> enforcement. This external policy system evaluates the policies based on <br>
> what information nova passes it, which would require the policy check <br>
> string, context of the request like the user, and the resource they are <br>
> trying operate on (the instance in this case). The external policy <br>
> system could query it's own policy database for any policies matching <br>
> that data, run the decisions, and return the enforcement decision per <br>
> the oslo.limit API.<br>
<br>
One thing I'm pretty sure of in nova is we do not do a great job of <br>
getting the target of the policy check before actually doing the check. <br>
In other words, our target is almost always the project/user from the <br>
request context, and not the actual resource upon which the action is <br>
being performed (the server in most cases). I know John Garbutt had a <br>
spec for this before. It always confused me.<br></blockquote><div><br></div><div>I doubt nova is alone in this position. I would bet there are a lot of cases across OpenStack where we could be more consistent in how this information is handed to oslo.policy. We attempted to solve this for the other half of the equation, which is the `creds` dictionary. Turns out a lot of what was in this arbitrary `creds` dict, was actually just information from the request context object. The oslo.policy library now supports context objects directly [0], as opposed to hoping services build the dictionary properly. Target information will be a bit harder to do because it's different across services and even APIs within the same service. But yeah, I totally sympathize with the complexity it puts on developers.</div><div><br></div><div>[0] <a href="https://review.openstack.org/#/c/578995/">https://review.openstack.org/#/c/578995/</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">
<br>
> <br>
> Conversely, you'll have a performance hit since the policy decision and <br>
> policy enforcement points are no longer oslo.policy *within* nova, but <br>
> some external system being called by oslo.policy...<br>
<br>
Yeah. The other thing is if I'm just looking at my server, I can see if <br>
it's locked or not since it's an attribute of the server resource. With <br>
policy I would only know if I can perform a certain action if I get a <br>
403 or not, which is fine in most cases. Being able to see via some list <br>
of locked actions per server is arguably more user friendly. This also <br>
reminds me of reporting / capabilities APIs we've talked about over the <br>
years, e.g. what I can do on this cloud, on this host, or with this <br>
specific server?<br></blockquote><div><br></div><div>Yeah - I wouldn't mind picking that conversation up, maybe in a separate thread. An idea we had with keystone was to run a user's request through all registered policies and return a list of the ones they could access (e.g., take my token and tell me what I can do with it.) There are probably other issues with this, since policy names are mostly operator facing and end users don't really care at the moment.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> <br>
> Might not be the best idea, but food for thought based on the <br>
> architecture we have today.<br>
<br>
Definitely, thanks for the alternative. This is something one could <br>
implement per-provider based on need if we don't have a standard solution.<br></blockquote><div><br></div><div>Right, I always thought it would be a good fit for people providing super-specific policy checks or have a custom syntax they want to implement. It keeps most of that separate from the services and oslo.policy. So long as we pass target and context information consistently, they essentially have an API they can write policies against.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
<br>
Thanks,<br>
<br>
Matt<br>
<br>
</blockquote></div></div></div>