Add group-level-only integrations, a propagation opt-out, and integration audit events

What does this MR do and why?

Extends the integration framework for the Workday integration in https://gitlab.com/gitlab-org/gitlab/-/work_items/629838, which must exist only on a top-level group, must never be copied to descendants, and must have its changes audited.

Behaviour change: in GitLab Enterprise Edition, creating, updating or deleting an integration from its settings page or the REST API now records an audit event. Integrations saved another way (the Slack app installation, exclusions, Amazon Q, and the GitHub CI/CD setup) are not covered. The three hooks below change nothing for existing integrations.

Hook What it does Default
Integration.group_specific_integration_names Integrations that can be enabled only at the group level. Project lookups, the instance list, and the project GraphQL enum (CE and EE) leave these names out. Empty list
Integration.available_for_group?(group) Lets an integration limit itself to some groups, for example top-level groups. Unavailable integrations are hidden from the group settings pages and the group REST API, and return 404 or 400 when requested directly. true
Integration#propagatable? Lets an integration opt out of being copied to descendant groups and projects. true

Audit events

  • Event types: integration_created, integration_updated and integration_deleted. The message is "<Title> integration was created", with the author and no other data. The title is always in the default locale.
  • Scope: the project or group where the integration is set up. Instance and organization integrations are recorded at instance scope.
  • Where they are recorded:
    • The group, instance and organization settings forms (save and reset), through Integrations::Actions.
    • The project settings form (save), through Projects::Settings::IntegrationsController.
    • The REST API PUT, through Integrations::UpdateService.
    • The REST API DELETE, through a new after_disable hook.
  • Propagation records nothing. Copying settings to descendant groups and projects uses bulk updates, so one save is one event.
  • EE only: the hooks in CE are empty, and the recording is in ee/.

Other changes

  • Integrations::Actions runs its availability check before reset, so resetting an unavailable integration returns 404. The reset override in Admin::Organizations::IntegrationsController became redundant and is removed.
  • reset does not record integration_deleted for an integration that was never saved.

Decisions for reviewers

  1. Audit events cover all integrations saved from the settings pages or the REST API. An earlier version of this MR made them opt-in. That was dropped in https://gitlab.com/gitlab-org/gitlab/-/work_items/629838#note_4244233090.
  2. Audit events are recorded at the write paths, not in a model callback. A callback has no acting user.
  3. REST API DELETE records integration_updated. That endpoint blanks the fields and deactivates the row, but does not delete it. Only the form's reset deletes the row.

This MR was extracted from !270885 (merged), which is stacked on top of it.

References

Screenshots or screen recordings

Not applicable. There is no UI change.

How to set up and validate locally

  1. On an instance with an Ultimate license, save any group or project integration, for example Asana.

  2. Go to the group's or project's Secure > Audit events. An "Asana integration was created" event is listed.

  3. Save it again, then reset it from a group. The updated and deleted events are listed.

  4. Run the specs:

    bundle exec rspec spec/models/integration_spec.rb spec/workers/propagate_integration_worker_spec.rb spec/controllers/groups/settings/integrations_controller_spec.rb
    bundle exec rspec spec/models/group_spec.rb -e find_or_initialize_integration
    bundle exec rspec ee/spec/services/integrations/audit_service_spec.rb ee/spec/services/ee/integrations/update_service_spec.rb
    bundle exec rspec ee/spec/requests/ee/groups/settings/integrations_controller_spec.rb ee/spec/requests/ee/projects/settings/integrations_controller_spec.rb
    bundle exec rspec ee/spec/graphql/ee/types/projects/service_type_enum_spec.rb spec/requests/admin/organizations/integrations_controller_spec.rb

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 Tanishq Jain

Merge request reports

Loading
Loading