Add read_subscription_usage for Organization owners
What does this MR do and why?
Lets Organization owners read GitLab Credits usage at the Organization, the first step of moving the credits dashboard there.
- Grants
read_subscription_usageto the Organization owner role (config/authz/roles/organization_owner.yml). - Blocks it with a
preventrule unlessorganization_billingis enabled for the Organization and the Organization has a billing namespace. The default Organization and Organizations without a linked subscription never get it. - Introduces the
organization_billingwipflag (Organization actor,default_enabled: false). If #635623 merges first, this MR reuses its definition instead.
Instance admins don't get the permission. An admin is often also a group owner, and Organization billing usage shouldn't be visible to them through admin mode.
Note
This MR depends on #635621 (closed), which adds Organization#billing_namespace. The policy and specs call that method, so the specs fail until it merges. This MR stays in draft until then.
References
- Resolves #635330 (closed)
- Parent epic: gitlab-org#23740
- Blocked by #635621 (closed)
Screenshots or screen recordings
Not applicable: permission and policy change only, no UI.
How to set up and validate locally
Requires #635621 (closed) in your branch.
-
Seed an Organization billed through a nominated group. The seed makes the seeded admin (
root) its owner:bin/rake db:seed_fu FILTER=organization_gitlab_subscriptions -
In the Rails console, check the permission with the flag off and on:
organization = Organizations::Organization.find_by(path: 'billed-organization') owner = User.find_by_username('root') Ability.allowed?(owner, :read_subscription_usage, organization) # => false Feature.enable(:organization_billing, organization) Ability.allowed?(owner, :read_subscription_usage, organization) # => true
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.