Self-Managed administrators define lasting custom <iframe> providers

What does this MR do and why?

Let Self-Managed administrators define their own <iframe> providers in gitlab.yml, where they survive upgrades. Prompted by #282443 (comment 4240404385).

This is already de-facto permitted by modifying config/iframe_providers.yml, but it gets overwritten on each upgrade. We use the same pattern as OmniAuth providers to permit persistent admin config of these: providers in gitlab.yml go after the ones we ship, and those with overlapping IDs replace ours.

Replacement is intentional. AppSec review on config/iframe_providers.yml is there so changes on our side can't weaken GitLab.com; it isn't there to stop admins doing what they like with their own infrastructure.

No changelog, FF'd.

See also:

Screenshots or screen recordings

Using the following under development.gitlab in config/gitlab.yml:

iframe_providers:
  openstreetmap:
    name: OpenStreetMap
    matches:
      - host: www.openstreetmap.org
        path: /export/embed.html
        params: [bbox]
    src: https://www.openstreetmap.org/export/embed.html?bbox={bbox}
    view: https://www.openstreetmap.org/export/embed.html?bbox={bbox}
    sandbox: [allow-scripts, allow-same-origin]
    require_activation: false
  youtube:
    name: YouTube (click to load)
    matches:
      - host: www.youtube.com
        path: /embed/{v}
      - host: www.youtube.com
        path: /watch
        params: [v]
      - host: youtu.be
        path: /{v}
    src: https://www.youtube.com/embed/{v}
    view: https://www.youtube.com/watch?v={v}
    sandbox: [allow-scripts, allow-same-origin]
    require_activation: true
What Before After
Admin settings before-admin-settings-master.png after-admin-settings-branch.png
Issue N/A: provider not defined after-issue-branch.png

Note that master ignores the config entirely. On this branch OpenStreetMap is listed and loads straight away, while YouTube takes its replacement's name and now waits for a click.

How to set up and validate locally

  1. On master, add the providers above under development.gitlab in config/gitlab.yml, and restart Rails. Restart after every change to gitlab.yml: providers are loaded once per process.

  2. Visit Admin → Settings → General, and expand Embedded content. It should look like the "Before" side: only YouTube and Figma are listed, and YouTube doesn't have "(click to load)" after it.

  3. Check out this branch, and restart Rails.

  4. Revisit the settings. It should look like the "After" side. Select "Enable embedded content" and "YouTube (click to load)" if they aren't already, select OpenStreetMap, and save.

  5. In the Rails console, enable the allow_iframes_in_markdown feature flag:

    Feature.enable(:allow_iframes_in_markdown)
  6. Create an issue containing:

    ![Map](https://www.openstreetmap.org/export/embed.html?bbox=-0.1,51.5,-0.09,51.51)
    
    ![Video](https://www.youtube.com/watch?v=12yWKw1AdKY)

    The map should load straight away, and the video should show a placeholder until you select "Load external content".

  7. Change the OpenStreetMap provider's sandbox to [allow-forms], which isn't a permitted flag, and restart Rails. GitLab should still come up, but with no providers at all: none are listed in the settings, and log/application_json.log has an Ignoring iframe provider configuration entry naming the provider and the flag.

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 Asherah Connor

Merge request reports

Loading
Loading