Here is a vision of how we want policy to be enforced in nova.
There are several problems for current API policy.
These are the kinds of things we need to make easier:
1. Operator wants to enable a specific role to access the service API which is not possible because there is currently a hard coded admin check.
2. One policy rule per API action. Having a check in the REST API and a redundant check in the compute API can confuse developers and deployers.
4. Operator can override the default policy rule easily without mixing his own config and default config in one policy.json file.
The generic rule for all the improvement is keep V2 API back-compatible. Because V2 API may be deprecated after V2.1 parity with V2. This can reduce the risk we take. The improvement just for EC2 and V2.1 API. There isn't any user for V2.1, as it isn't ready yet. We have to do change for EC2 API. EC2 API won't be removed like v2 API. If we keep back-compatible for EC2 API also, the old compute api layer checks won't be removed forever. EC2 API is really small than Nova API. It's about 29 APIs without volume and image related(those policy check done by cinder and glance). So it will affect user less.
The policy should be only enforced at REST API layer. This is clear for user to know where the policy will be enforced. If the policy spread into multiple layer of nova code, user won't know when and where the policy will be enforced if they didn't have knowledge about nova code.
Remove all the permission checking under REST API layer. Policy will only be enforced at REST API layer.
This will affect the EC2 API and V2.1 API, there are some API just have policy enforcement at Compute/Network API layer, those policy will be move to API layer and renamed.
Hard-coded permission checks make it impossible to supply a configurable policy. They should be removed in order to make nova auth completely configurable.
This will affect EC2 API and Nova V2.1 API. User need update their policy rule to match the old hard-code permission.
For Nova V2 API, the hard-code permission checks will be moved to REST API layer to guarantee it won't break the back-compatibility. That may ugly some hard-code permission check in API layer, but V2 API will be removed once V2.1 API ready, so our choice will reduce the risk.
This feature make deployer can override default policy rule easily. And When nova default policy config changed, deployer only need replace default policy config files with new one. It won't affect his own policy config in other files.
Currently all the APIs(Nova v2/v2.1 API, EC2 API) use same set of policy rules. Especially there isn't obvious mapping between those policy rules and EC2 API. User can know clearly which policy should be configured for specific API.
Nova should provide different prefix for policy rule name that used to group them, and put them in different policy configure file in policy.d
This will affect EC2 API and V2.1 API. For EC2 API, it need deployer update their policy config. For V2.1 API, there isn't any user yet, so there won't any effect.
After group the policy rules for different API, we can separate them into different files. Then deployer will more clear for which rule he can set for specific API. The rules can be grouped as below:
policy.json: It only contains the generic rule, like:
"context_is_admin": "role:admin",
"admin_or_owner": "is_admin:True or project_id:%(project_id)s",
"default": "rule:admin_or_owner",
policy.d/00-ec2-api.conf: It contains all the policy rules for EC2 API.
policy.d/00-v2-api.conf: It contains all the policy rules for nova V2 API.
policy.d/00-v2.1-api.conf: It contains all the policy rules for nova v2.1 API.
The prefix '00-' is used to order the configure file. All the files in policy.d will be loaded by alphabetical order. '00-' means those files will be loaded very early.
Nova provide default policy rules for all the APIs. Operator should only make the policy rule more permissive. If the Operator make the API to be restricted that make break the existed API user or application. That's kind of back-incompatible. SO Operator can free to add additional permission to the existed API.
In the legacy v2 API, the policy enforces with target object, and some operators implement user-based authorization based on that. Actually only project-based authorization is well tested, the user based authorization is untested and isn't supported by Nova. In the future, the nova will remove all the supports for user-based authorization.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.