Skip to content

Added headers hash for http destinations

Hitesh Raghuvanshi requested to merge 436607-http-headers into master

What does this MR do and why?

This MR adds a method for us to return headers_hash from any model that composes the ExternallyStreamable concern. It overwrites any attempt to write over X-Gitlab-Event-Streaming-Token which is set to the secret_token (generated or user provided)

This MR also updates the json schema file for HTTP categories, and uses the HTTP RFC-7230 to allow certain characters.

  • It is pretty permissive on what is allowed (USASCII, special characters, spaces, etc.)
  • An alternative is to use what Cloudflare defines as acceptable header keys and values format: Reference
  • It also disallows any 'custom' properties, so only value and active are passable

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Checkout the git branch
  2. Create new external streaming destinations using graphql with the category http
  3. Open rails console and query for streaming destinations [AuditEvents::Instance::ExternalStreamingDestination]
  4. Validate that headers_hash is returned for http category destinations
Example graphql query
mutation CreateInstanceAuditEventStreamingDestination {
  instanceAuditEventStreamingDestinationsCreate(
    input: {
      config: {
        url:"https://gitlab.com/test",
        headers: { key1: { value: "test", active: true } }
      },
      category: "http", 
      secretToken:"my-token-my-token-12345",
    }
  ) {
    externalAuditEventDestination {
      id
      name
      category
      config
    }
    errors
  }
}

Related to #436607 (closed)

Edited by Andrew Jung

Merge request reports

Loading