Enhance Ceilometer API Role Based Access Control in Preparation for Keystone v3 API
Current access control for the API is all or nothing. A policy.json file is used but it simply determines if the user is admin, granting all privileges, or scoping for a single project.
With upcoming Keystone v3 enhancements we can expand the granularity of access control to allow cross-project access by non-admins. This functionality will be useful for admins of groups of users/tenants who should not be the admin of the entire system.
We will accomplish this by using a decorator on the API functions. The decorator will control access based on user/tenant roles and rules specified in the policy json file.
Example of decorator usage in v2 reporting API:
@wsme_
@rbac_
def get_all(self, q=None, limit=None):
"""Return samples for the meter.
:param q: Filter rules for the data to be returned.
:param limit: Maximum number of samples to return.
"""
Decorator contains code similar to what's in acl.py already, but sets project/users here instead of various places within the v2.py code:
def protected(
global _ENFORCER
if not _ENFORCER:
_ENFORCER = policy.Enforcer()
def wrapper(f):
def inner(self, **kwargs):
if not _ENFORCER.
return f(self, **kwargs)
return inner
return wrapper
acl.py could be deprecated since its only function is to determine if a user is admin, and the decorator accomplishes this.
Example policy expansions:
Current policy.json only verifies user is admin:
{
"context_
}
New rules allow separation of access control by method and expanded roles. Also compatible with Keystone v3 expanded functionality where domains are supported.
{
"context_
"admin_
"telemetry:
}
Blueprint information
- Status:
- Complete
- Approver:
- Eoghan Glynn
- Priority:
- High
- Drafter:
- Eric Pendergrass
- Direction:
- Approved
- Assignee:
- Fabio Giannetti
- Definition:
- Approved
- Series goal:
- Accepted for kilo
- Implementation:
- Implemented
- Milestone target:
- 2015.1.0
- Started by
- Eoghan Glynn
- Completed by
- Eoghan Glynn
Related branches
Related bugs
Sprints
Whiteboard
De facto approval of the corresponding specs review:
https:/
Implemented by: