Skip to content

Include session_cookie_token_prefix in KAS session cookie

What does this MR do and why?

Builds upon the changes added in !145178 (merged) to add the configured prefix to the _kas_session cookie used for the Kubernetes Dashboard. This will allow routing dashboard requests to the correct KAS/cell.

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

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

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

  1. Configure GDK with KAS and an agent that is set up for user access
  2. Add gdk.yml config to use a cookie prefix:
     gitlab:
       rails:
         session_store:
           session_cookie_token_prefix: 'test_prefix_'
  3. Run gdk reconfigure and gdk restart to pick up the changes.
  4. Browse to the overview page of the agent
  5. In the network tab of developer tools, observe the prefix has been set in the cookie value, for example: Screenshot_2024-05-31_at_2.25.46_PM
  6. In the browser console, execute the following (substituting the correct agent ID and KAS address):
     fetch('https://gdk.test:3443/-/k8s-proxy/api/v1/namespaces', {credentials: 'include', headers: {'X-Csrf-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content, 'GitLab-Agent-Id': '17'}}).then((response) => response.json()).then((data) => console.log(data));
  7. The call should succeed and list the namespaces in your agent's cluster.

Related to #444679 (closed)

Edited by Tiger Watson

Merge request reports