Skip to content

Add flavor permission rules - #581

Open
seb-kro wants to merge 4 commits into
stable/2025.1-m3from
I759286/flavor_permission_rules
Open

seb-kro wants to merge 4 commits into
stable/2025.1-m3from
I759286/flavor_permission_rules

Conversation

@seb-kro

@seb-kro seb-kro commented Nov 4, 2025

Copy link
Copy Markdown

Flavor Permission Rules

To support external customers, we want to restrict access to public flavors for arbitrary domains while keeping these flavors publicly accessible on other domains without additional configuration needs. Additionally, we want to enable project owners to configure project-specific public flavor access.

This adds flavor permission rules as a new mechanism for controlling flavor access. These rules do only apply to public flavors. Private flavors continue to be controlled exclusively via the flavor access list.

Each flavor permission rule has a domain_id, an optional project_id, an optional flavor_id and an effect (allow or deny).

The two scopes of flavor permission rules are derived from the project hierarchy:

  • domain scope rules have no project_id. They apply to all projects within their domain
  • project scope rules have a project_id of a non-domain project. They apply only to that project itself and are not inherited by sub-projects

A flavor can be accessed by a project if it is allowed at both the domain scope and the project scope.

Flavor-specific rules have a flavor_id and based on their effect either allow or deny the use of that flavor for their scope. Rules without a flavor_id define the default behavior for their scope. I.e., whether flavors without a flavor-specific rule are allowed or denied. If no default behavior rule exists, then all such flavors are allowed.

There is at most one flavor permission rule for each combination of domain_id, project_id and flavor_id. Consequently, a flavor is only denied at a scope if the corresponding domain or project:

  • has a deny rule matching the flavor_id
  • OR has a deny rule without a flavor_id AND no allow rule matching the flavor_id

Further Info

@seb-kro
seb-kro force-pushed the I759286/flavor_permission_rules branch from 1108c89 to 76b89e5 Compare November 5, 2025 01:30
@seb-kro
seb-kro force-pushed the I759286/flavor_permission_rules branch 5 times, most recently from fb0d424 to 0ecf556 Compare July 10, 2026 13:44
@seb-kro
seb-kro force-pushed the I759286/flavor_permission_rules branch from 0ecf556 to 5401635 Compare July 24, 2026 13:37
@seb-kro
seb-kro force-pushed the I759286/flavor_permission_rules branch from 5401635 to 13d2e32 Compare August 28, 2026 08:43
@seb-kro
seb-kro force-pushed the I759286/flavor_permission_rules branch from 13d2e32 to 9f30865 Compare September 7, 2026 09:42
@seb-kro
seb-kro force-pushed the I759286/flavor_permission_rules branch 2 times, most recently from d73a561 to 77fe2e2 Compare September 14, 2026 14:51
Flavor access is currently controlled via private/public flavors and the
flavor access list aka `FlavorProjects`. To restrict access to a flavor,
it must be private and access must be granted individually to each
project.

To support external customers, we want to restrict access to public
flavors for arbitrary domains while keeping these flavors publicly
accessible on other domains without additional configuration needs.
Additionally, we want to enable project owners to configure
project-specific public flavor access.

This adds the data model, database migration and `oslo.object` for
flavor permission rules: a new mechanism for controlling flavor access.
These rules do only apply to public flavors. Private flavors continue
to be controlled exclusively via the flavor access list.

Each flavor permission rule has a `domain_id`, an optional `project_id`,
an optional `flavor_id` and an `effect` (`allow` or `deny`).

The two scopes of flavor permission rules are derived from the project
hierarchy:
- `domain` scope rules have no `project_id`. They apply to all projects
  within their domain
- `project` scope rules have a `project_id` of a non-domain project.
  They apply only to that project itself and are not inherited by
  sub-projects
A flavor can be accessed by a project if it is allowed at both the
domain scope and the project scope.

Flavor-specific rules have a `flavor_id` and based on their effect
either allow or deny the use of that flavor for their scope. Rules
without a `flavor_id` define the default behavior for their scope. I.e.,
whether flavors without a flavor-specific rule are allowed or denied.
If no default behavior rule exists, then all such flavors are allowed.

There is at most one flavor permission rule for each combination of
`domain_id`, `project_id` and `flavor_id`. Consequently, a flavor is
only denied at a scope if the corresponding domain or project:
- has a `deny` rule matching the `flavor_id`
- OR has a `deny` rule without a `flavor_id` AND no `allow` rule
  matching the `flavor_id`

Change-Id: I5e1332d111c07ee714f2965c558f393c8568ffaf
We enforce flavor permission rules for all flavor object get functions
by extending the filtering of the query function
`_flavor_get_query_from_db`.

The filtering is based on the context's `project_domain_id` and
`project_id`. For each scope, public flavors are filtered by their
effective permission which is derived from both the flavor-specific and
the default behavior flavor permission rules. So a flavor is denied for
a domain or project if:
- there is a `deny` rule matching the `flavor_id`
- OR there is a `deny` rule without a `flavor_id` AND there is no
  `allow` rule matching the `flavor_id`

Filter options are passed to the relevant get-function via
`domain_permission` and `project_permission` parameters:
- ALLOW returns non-public flavors and public flavors allowed by flavor
  permission rules (enforce permission rules)
- DENY returns (public) flavors denied by flavor permission rules
- None returns all flavors (no permission filtering)

Just like the existing flavor privacy mechanisms (private flavors/flavor
access list), flavor permission rules do not take effect for admin
contexts and do not restrict the flavor object create, save and destroy
methods in any way.

We also implement new `get_permission(s)` functions to return the
effective domain and project permission for flavors and flavor lists.

The `Flavor` and `FlavorList` hashes in `test_objects` are updated to
reflect the new fingerprints that result from adding new parameters
to the remotable class methods. Since the parameter has a default, the
method signature changes are backward-compatible and we do not bump the
object versions.

Change-Id: Ic17dcc21a07a383e26822a5fbf7cf5cfc5383ec6
Adds API endpoints for managing flavor permission rules:
- GET    `/flavor-permission-rules`
- POST   `/flavor-permission-rules`
- GET    `/flavor-permission-rules/{id}`
- PUT    `/flavor-permission-rules/{id}`
- DELETE `/flavor-permission-rules/{id}`

The index action checks three policies to determine which rules are
visible to the caller
- `index:all`: all rules
- `index:domain`: rules belonging to the context's `project_domain_id`
- `index:project`: rules belonging to the context's `project_id`

Show, create, update and delete each enforce a per-scope policy
(e.g. `create:domain`, `create:project`). This lets operators separately
restrict access to:
- domain-scope rules based on the context's `project_domain_id`
- project-scope rules based on the context's `project_domain_id` and
  `project_id`

Change-Id: I8397afed673e7ffbae8bef0870cacb1bd07601d1
Add optional parameters `domain_permission` and `project_permission` to
the flavor `index` and `detail` endpoints. These allow filtering flavors
by the effective flavor permission (`allow`, `deny`) for the context
project domain and context project. The effective flavor permission for
each scope is derived from both the flavor-specific and default behavior
flavor permission rules. Equivalent to flavor extra specs, the usage of
these parameters is restricted by the existing flavor permission rule
`index` policies. Correspondingly, we add HTTP Code 403 (forbidden) as
an expected error.

The flavor `detail` and `show` endpoints now also return the effective
flavor permissions for the current context project domain and context
project for users with the relevant flavor permission rule access.

Change-Id: I5ad7e2a932755218f31c97509a8814dac329fa0a
@seb-kro
seb-kro force-pushed the I759286/flavor_permission_rules branch from 77fe2e2 to ced5be4 Compare September 15, 2026 09:42
@seb-kro
seb-kro changed the base branch from stable/2023.2-m3 to stable/2025.1-m3 September 15, 2026 09:47
@seb-kro
seb-kro marked this pull request as ready for review September 15, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant