X-Forwarded-Host check in workhorse duo workflow

What does this MR do and why?

This MR adds a custom CheckOrigin for duo workflow websocket connection in workhorse.

References

Resolves #573457

Screenshots or screen recordings

How to set up and validate locally

  1. Make a websocket request
curl -v \
  -H "Origin: http://gdk.test:3000" \
  -H "Host: gdk.test:3333" \
  -H "Upgrade: websocket" \
  -H "Connection: Upgrade" \
  -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
  -H "Sec-WebSocket-Version: 13" \
  -H "Authorization: Bearer <your-token>" \
  "http://gdk.test:3333/api/v4/ai/duo_workflows/ws"

you should receive 101 2. Enable the feature flag

Feature.enable(:duo_workflow_check_origin_by_forwarded_host)
  1. Make a request without X-Forwarded-Host
curl -v \
  -H "Origin: http://gdk.test:3000" \
  -H "Host: gdk.test:3333" \
  -H "Upgrade: websocket" \
  -H "Connection: Upgrade" \
  -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
  -H "Sec-WebSocket-Version: 13" \
  -H "Authorization: Bearer <your-token>" \
  "http://gdk.test:3333/api/v4/ai/duo_workflows/ws"

You should receive 401 3. Make a request with matching X-Forwarded-Host

curl -v \
  -H "Origin: http://gdk.test:3000" \
  -H "Host: gdk.test:3333" \
  -H "X-Forwarded-Host: gdk.test:3000" \
  -H "Upgrade: websocket" \
  -H "Connection: Upgrade" \
  -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
  -H "Sec-WebSocket-Version: 13" \
  -H "Authorization: Bearer <your-token>" \
  "http://gdk.test:3333/api/v4/ai/duo_workflows/ws"

You should receive 101

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.

Merge request reports

Loading
Loading