Skip to content

Commit 66e3c56

Browse files
committed
feat(FR-2629): extend tokenLogin helper with optional extraParams
Add an optional fifth parameter `extraParams?: Record<string, string>` to the `tokenLogin` helper in `loginSessionAuth.ts`. When provided, it is forwarded to `client.token_login(sToken, extraParams)` so callers can pass additional query parameters collected from the URL (e.g. EduAppLauncher's `app`, `session_id`, `cpu`, `mem`). Existing LoginView caller remains valid since the parameter is optional and defaults to an empty object internally. This closes Open Question 1 from the spec (option (a) — extend over bypass). Refs FR-2616
1 parent 5a1570c commit 66e3c56

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

react/src/helper/loginSessionAuth.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,35 @@ export async function connectViaGQL(
171171

172172
/**
173173
* Perform token-based login (SSO).
174+
*
175+
* `extraParams` are forwarded to `client.token_login` alongside the `sToken`
176+
* argument. Callers typically collect these from URL query parameters (for
177+
* example, EduAppLauncher forwards `app`, `session_id`, resource hints) for
178+
* the server-side token handler. LoginView callers that do not need to
179+
* forward anything can omit the argument.
180+
*
181+
* Reserved keys (`sToken`, `stoken`) are stripped from `extraParams` before
182+
* forwarding so that the explicit `sToken` argument always wins, regardless
183+
* of whether a caller accidentally (or maliciously) included the token in
184+
* the forwarded query parameters. `client.token_login` merges `extraParams`
185+
* into the request body via `Object.assign`, so an unsanitized map would
186+
* otherwise overwrite the authenticated token field.
174187
*/
175188
export async function tokenLogin(
176189
client: any,
177190
sToken: string,
178191
cfg: LoginConfigState,
179192
endpoints: string[],
193+
extraParams?: Record<string, string>,
180194
): Promise<string[]> {
181-
const loginSuccess = await client.token_login(sToken);
195+
const sanitizedExtraParams = extraParams
196+
? Object.fromEntries(
197+
Object.entries(extraParams).filter(
198+
([key]) => key !== 'sToken' && key !== 'stoken',
199+
),
200+
)
201+
: {};
202+
const loginSuccess = await client.token_login(sToken, sanitizedExtraParams);
182203
if (!loginSuccess) {
183204
throw new Error('Cannot authorize session by token.');
184205
}

0 commit comments

Comments
 (0)