Skip to content

fix(eng-10262): added correct encoding of next query parameter#883

Open
ihorsokhanexoft wants to merge 1 commit intoCenterForOpenScience:feature/pbs-26-2from
ihorsokhanexoft:fix/ENG-10262
Open

fix(eng-10262): added correct encoding of next query parameter#883
ihorsokhanexoft wants to merge 1 commit intoCenterForOpenScience:feature/pbs-26-2from
ihorsokhanexoft:fix/ENG-10262

Conversation

@ihorsokhanexoft
Copy link

@ihorsokhanexoft ihorsokhanexoft commented Feb 13, 2026

https://openscience.atlassian.net/browse/ENG-10262

Purpose

For LOCAL env only:

A new next query parameter must be the first one to be encrypted and then encrypted one more time with service query parameter together.
So everything after localhost:8080/login?service= is encrypted and the next query param with its value is encrypted twice.

Also in the middle of the url, we should use ? instead of & (%3F - encoded, between login and next words) so that the next parameter belongs to service, not the main request

http://192.168.168.167:8080/login?service=http%3A%2F%2Flocalhost%3A5000%2Flogin%3Fnext%3Dhttp%253A%252F%252Flocalhost%253A4200%252F

And CAS should handle login, not angular, so we replace 4200 port in service query parameter by 5000

Comment on lines +7 to +16
export const localUrlParam = (params: { service: string; next?: string }) => {
const { service, next } = params;

// encode "next" separately because it must be encoded twice
const encodedNext = next ? encodeURIComponent(next) : undefined;

const valueAfterService = encodedNext ? `${service}?next=${encodedNext}` : service;

return `service=${encodeURIComponent(valueAfterService)}`;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export const localUrlParam = (params: { service: string; next?: string }) => {
const { service, next } = params;
// encode "next" separately because it must be encoded twice
const encodedNext = next ? encodeURIComponent(next) : undefined;
const valueAfterService = encodedNext ? `${service}?next=${encodedNext}` : service;
return `service=${encodeURIComponent(valueAfterService)}`;
};
export const localUrlParam = (params: { service: string; next?: string }): string => {
const { service, next } = params;
if (!next) {
return `service=${encodeURIComponent(service)}`;
}
const encodedNext = encodeURIComponent(next);
const valueAfterService = `${service}?next=${encodedNext}`;
return `service=${encodeURIComponent(valueAfterService)}`;
};

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