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_updatedandintegration_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, throughIntegrations::UpdateService. - The REST API
DELETE, through a newafter_disablehook.
- The group, instance and organization settings forms (save and reset), through
- 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::Actionsruns its availability check beforereset, so resetting an unavailable integration returns404. Theresetoverride inAdmin::Organizations::IntegrationsControllerbecame redundant and is removed.resetdoes not recordintegration_deletedfor an integration that was never saved.
Decisions for reviewers
- 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.
- Audit events are recorded at the write paths, not in a model callback. A callback has no acting user.
- REST API
DELETErecordsintegration_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
- Issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/629838
- First consumer: !270885 (merged)
- Epic: https://gitlab.com/groups/gitlab-org/-/work_items/23625
Screenshots or screen recordings
Not applicable. There is no UI change.
How to set up and validate locally
-
On an instance with an Ultimate license, save any group or project integration, for example Asana.
-
Go to the group's or project's Secure > Audit events. An "Asana integration was created" event is listed.
-
Save it again, then reset it from a group. The updated and deleted events are listed.
-
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.