Added headers hash for http destinations
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
andactive
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.
- Checkout the
git branch
- Create new external streaming destinations using graphql with the category
http
- Open
rails console
and query for streaming destinations [AuditEvents::Instance::ExternalStreamingDestination] - Validate that
headers_hash
is returned forhttp
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