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_usage to the Organization owner role (config/authz/roles/organization_owner.yml).
  • Blocks it with a prevent rule unless organization_billing is 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_billing wip flag (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

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.

  1. 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
  2. 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.

Edited by Harsh Vardhan Sharma

Merge request reports

Loading
Loading