Skip to content

Add custom_roles to security policies API

What does this MR do and why?

This MR updates the existing graphql and REST APIs with custom_roles as we will be supporting custom roles as approvers with &13550 (closed)

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshot_2024-12-11_at_8.29.57_PM

How to set up and validate locally

  • Create a group (make sure that there are members in the group) and a project within it
  • Create custom role for the instance (GDK is self-hosted) following the docs
  • Create a security policy (Merge Request approval policy) for the group by going to Secure->Policies and toggle to the YAML mode and update the policy content:
name: Custom Role
description: ''
enabled: true
actions:
- type: require_approval
  approvals_required: 1
  role_approvers:
  - developer
  - 1
- type: send_bot_message
  enabled: true
rules:
- type: any_merge_request
  branch_type: protected
  commits: any
approval_settings:
  block_branch_modification: true
  prevent_pushing_and_force_pushing: true
  prevent_approval_by_author: true
  prevent_approval_by_commit_author: true
  remove_approvals_with_new_commit: true
  require_password_to_approve: false
fallback_behavior:
  fail: closed
  • Go to http://gdk.test:3000/-/graphql-explorer and execute the query:
{
  project(fullPath:<project path>) {
    approvalPolicies {
      nodes{
        actionApprovers {
          customRoles{
            id
            name
          }
        }
      }
    }
  }
}

Related to #505167 (closed)

Edited by Sashi Kumar Kumaresan

Merge request reports

Loading