Skip to content

WS-2449: Use cookie auth for UAS instead of Authorization header#13876

Open
elvinasv wants to merge 2 commits intolatestfrom
ws-2449-use-cookie-auth-for-uas-requests
Open

WS-2449: Use cookie auth for UAS instead of Authorization header#13876
elvinasv wants to merge 2 commits intolatestfrom
ws-2449-use-cookie-auth-for-uas-requests

Conversation

@elvinasv
Copy link
Copy Markdown
Member

@elvinasv elvinasv commented Apr 3, 2026

Resolves JIRA: https://bbc.atlassian.net/browse/WS-2449

Summary

  • Use cookie based auth (where ckns_atkn is attacked to the request) instead of authorization header

Code changes

  • List key code changes that have been made.

Testing

  1. List the steps required to test this PR.

Useful Links

@elvinasv elvinasv marked this pull request as ready for review April 3, 2026 12:28
Copilot AI review requested due to automatic review settings April 3, 2026 12:28
@elvinasv elvinasv self-assigned this Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the UAS client authentication approach to rely on cookie-based auth rather than sending an Authorization bearer token header.

Changes:

  • Removes reading ckns_atkn from js-cookie and stops constructing Authorization / X-Authentication-Provider headers.
  • Keeps X-API-Key header generation and tightens the missing-config error to only cover the API key.

Comment on lines +6 to 12
if (!apiKey) {
throw new Error('Missing UAS public API key');
}

const headers: Record<string, string> = {
Authorization: `Bearer ${cknsAtkn}`,
'X-Authentication-Provider': 'idv5',
'X-API-Key': apiKey,
};
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change removes the Authorization / X-Authentication-Provider headers, but existing UAS request tests still assert those headers and also assert an error when the ckns_atkn cookie is missing. With cookie-based auth, these expectations should be updated (e.g. only assert X-API-Key, and remove/replace the cookie-missing error case) so CI reflects the new authentication mechanism.

Copilot uses AI. Check for mistakes.
import onClient from '#app/lib/utilities/onClient';
import { getEnvConfig } from '../utilities/getEnvConfig';

const getAuthHeaders = (): Record<string, string> => {
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is named getAuthHeader.ts but the exported function is getAuthHeaders. Consider renaming either the file or the function so singular/plural naming is consistent and easier to discover via imports/search.

Copilot uses AI. Check for mistakes.
if (!cknsAtkn || !apiKey) {
throw new Error('Missing authentication for UAS request');
if (!apiKey) {
throw new Error('Missing UAS public API key');
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thrown error is fairly generic; including the env var name (SIMORGH_UAS_PUBLIC_API_KEY) in the message would make misconfiguration easier to diagnose from logs.

Suggested change
throw new Error('Missing UAS public API key');
throw new Error(
'Missing required environment variable: SIMORGH_UAS_PUBLIC_API_KEY',
);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants