Slawek Kaplonski bd9d47aa36 Handle deprecated rule only once
The policy engine converts simple strings into instances of rule
objects based on a policy DSL. This engine iterates checks and reduces
them after each iteration if performing the conversion on list of check
strings.

When we deprecate policies we apply a logical OR to make upgrades easier
for operators. The logical OR, implemented with an OrCheck, only needs
to be done once per deprecated rule. Today, we're re-initializing an
OrCheck instance each time we load rules, which happens every time
oslo_policy.policy.Enforcer.enforce() is called.

For most OpenStack usage, this isn't noticiable, especially if you're
only using it to enforce access to a specific endpoint. However, this
can get expensive if you're using the enforcer to protect the API,
protect each resource in a response, and protect each attrbute of the
resource (e.g., Neutron makes extensive usage of this pattern to
implement RBAC for resources it's responsible for).

This commit updates the RuleDefault object to track state of handling
deprecated logic ORs so that we only cast the check strings to OrCheck
instances once per rule no matter how many times we call load_rules().

Closes-Bug: 1913718

Change-Id: I539672fc220b8d7e3c47ab3dfa6670b88e3f4093
2021-02-01 19:29:06 +00:00
2020-11-17 18:21:41 +00:00
2019-10-10 08:38:14 -07:00
2019-04-19 19:29:48 +00:00
2020-09-11 20:59:34 +00:00
2020-11-01 18:08:33 -08:00
2020-02-11 18:54:49 +01:00
2021-01-30 16:32:07 +00:00

Team and repository tags

image

oslo.policy

Latest Version

The Oslo Policy library provides support for RBAC policy enforcement across all OpenStack services.

Description
Rules engine to enforce access control policy
Readme 6.6 MiB
Languages
Python 100%