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:
- <iframe> embeds in Markdown content (#282443) — the feature work item.
- Self-Managed administrators define lasting cust... (omnibus-gitlab!10105 - merged) — the Omnibus-side MR to provide these settings.
- Self-Managed administrators define lasting cust... (gitlab-org/charts/gitlab!5608) — the Charts-side MR to provide these settings.
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 | ![]() |
![]() |
| Issue | N/A: provider not defined | ![]() |
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
-
On
master, add the providers above underdevelopment.gitlabinconfig/gitlab.yml, and restart Rails. Restart after every change togitlab.yml: providers are loaded once per process. -
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.
-
Check out this branch, and restart Rails.
-
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.
-
In the Rails console, enable the
allow_iframes_in_markdownfeature flag:Feature.enable(:allow_iframes_in_markdown) -
Create an issue containing:
 The map should load straight away, and the video should show a placeholder until you select "Load external content".
-
Change the OpenStreetMap provider's
sandboxto[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, andlog/application_json.loghas anIgnoring iframe provider configurationentry 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.


