Self-Managed administrators define lasting custom <iframe> providers

What does this MR do?

Propagate config for admin-defined <iframe> providers. gitlab_rails['iframe_providers'] is rendered into gitlab.yml, where Self-Managed administrators define lasting cust... (gitlab!271233 - merged) reads it.

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

Test plan

I ran this on a Linux package install in Docker (a 19.5.0 gitlab-ee image), applying this MR's attribute and gitlab.yml.erb changes to the package's cookbooks in /opt/gitlab/embedded/cookbooks for step 2 and onward.

The value is written out with to_json, so the plan covers the values that matter: strings with {name} placeholders, nested lists of hashes, and booleans.

  1. Without this MR (e.g. on master), add the following to /etc/gitlab/gitlab.rb, and run sudo gitlab-ctl reconfigure:

    gitlab_rails['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
      }
    }

    Reconfigure succeeds, but nothing reaches gitlab.yml:

    $ sudo /opt/gitlab/embedded/bin/ruby -ryaml -e 'p YAML.safe_load_file("/var/opt/gitlab/gitlab-rails/etc/gitlab.yml", aliases: true).dig("production", "gitlab", "iframe_providers")&.transform_values { |v| v.slice("src", "require_activation") }'
    nil
  2. With this MR, take the providers back out of gitlab.rb, and reconfigure. The command from step 1 still prints nil: nothing is rendered by default.

  3. Add the providers back, and reconfigure. They're now rendered under production.gitlab, placeholders and booleans intact:

    $ sudo /opt/gitlab/embedded/bin/ruby -ryaml -e 'p YAML.safe_load_file("/var/opt/gitlab/gitlab-rails/etc/gitlab.yml", aliases: true).dig("production", "gitlab", "iframe_providers")&.transform_values { |v| v.slice("src", "require_activation") }'
    {"openstreetmap" => {"src" => "https://www.openstreetmap.org/export/embed.html?bbox={bbox}", "require_activation" => false}, "youtube" => {"src" => "https://www.youtube.com/embed/{v}", "require_activation" => true}}

    The whole parsed value is equal to the hash set in gitlab.rb, including YouTube's three matches.

  4. Rails sees them:

    $ sudo gitlab-rails runner 'p = Gitlab.config.gitlab.iframe_providers.to_hash; puts p.keys.inspect; puts p["youtube"]["name"]; puts p["openstreetmap"]["sandbox"].inspect'
    ["openstreetmap", "youtube"]
    YouTube (click to load)
    ["allow-scripts", "allow-same-origin"]

    (Released Rails only exposes the setting; loading them as embed providers needs gitlab!271233 (merged), validated end-to-end against Self-Managed administrators define lasting cust... (gitlab-org/charts/gitlab!5608).)

Checklist

See Definition of done.

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

Required

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled workflowready for review per the Distribution MR workflow.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation created/updated.
  • Tests added.
  • Integration tests added to GitLab QA.
    • imho it's overkill and unwarranted (and not really in step with other similar MRs). Covered by ChefSpec.
  • Equivalent MR/issue for the GitLab Chart opened: Self-Managed administrators define lasting cust... (gitlab-org/charts/gitlab!5608).
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Asherah Connor

Merge request reports

Loading
Loading