Self-Managed administrators define lasting custom <iframe> providers

What does this MR do?

Propagate config for admin-defined <iframe> providers. global.appConfig.iframeProviders is rendered into the gitlab.yml of webservice, Sidekiq and toolbox, where Self-Managed administrators define lasting cust... (gitlab-org/gitlab!271233 - merged) reads it.

Note the feature itself is FF'd and pre-GA.

Validation on a real cluster

I validated this end-to-end on a local k3s cluster (Caproni), deploying this branch against the v19.5.5 images:

  1. Deploy this branch with providers set, pinning global.gitlabVersion to the images you're already running:

    global:
      gitlabVersion: v19.5.5
      appConfig:
        iframeProviders:
          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
  2. Each of the three ConfigMaps renders the providers:

    $ for cm in gitlab-webservice gitlab-sidekiq gitlab-toolbox; do kubectl -n gitlab get configmap $cm -o json | jq -r '.data["gitlab.yml.erb"]' | grep -c 'iframe_providers:'; done
    1
    1
    1
  3. Wait for the rollouts to finish (exec deploy/… can otherwise land on an old pod), then check the gitlab.yml CNG rendered in each pod parses with both providers. For toolbox:

    $ kubectl -n gitlab exec deploy/gitlab-toolbox -c toolbox -- ruby -ryaml -rjson -e 'p = YAML.safe_load(File.read("/srv/gitlab/config/gitlab.yml"), aliases: true)["production"]["gitlab"]["iframe_providers"]; puts p.keys.inspect; puts JSON.generate(p["openstreetmap"]["sandbox"]); puts p["youtube"]["view"]'
    ["openstreetmap", "youtube"]
    ["allow-scripts","allow-same-origin"]
    https://www.youtube.com/watch?v={v}

    Webservice (-c webservice) and Sidekiq (-c sidekiq) give the same output.

  4. Run gitlab-org/gitlab!271233 (merged) against that gitlab.yml. Released images ignore the key, so this needs the monolith MR; I used Caproni's edit mode, which copies gitlab.yml from the webservice pod. Then:

    • Admin → Settings → General → Embedded content lists "YouTube (click to load)", Figma and OpenStreetMap.
    • Once OpenStreetMap and YouTube are enabled there, gon.iframe_rendering_providers on any page has both, with YouTube's require_activation: true and narrower sandbox.
    • Markdown containing https://www.openstreetmap.org/export/embed.html?bbox=-0.1,51.5,-0.09,51.51 and https://www.youtube.com/watch?v=12yWKw1AdKY as images renders as two embeds, with provider IDs openstreetmap and youtube.

Author checklist

For general guidance, please follow our Contributing guide.

Required

For anything in this list which will not be completed, please provide a reason in the MR discussion.

  • Merge Request Title and Description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • MR has a green pipeline.
  • Documentation created/updated.
  • Tests added/updated.
  • Have you validated that your change works end-to-end on a real cluster deployment?
    • Describe how you did it in a comment.
  • Equivalent MR/issue for omnibus-gitlab opened: Self-Managed administrators define lasting cust... (gitlab-org/omnibus-gitlab!10105 - merged).
  • When ready for review, MR is marked as ready (not a draft) and assigned to a reviewer.

Reviewers checklist

Edited by Asherah Connor

Merge request reports

Loading
Loading