Skip to content

[MOL-13183] fetch userinfo from NDI#104

Merged
rgchua merged 7 commits intomasterfrom
MOL-13183
May 8, 2025
Merged

[MOL-13183] fetch userinfo from NDI#104
rgchua merged 7 commits intomasterfrom
MOL-13183

Conversation

@ryhuz
Copy link
Collaborator

@ryhuz ryhuz commented May 6, 2025

add methods for fetching userinfo from NDI using /userinfo

@rgchua
Copy link
Collaborator

rgchua commented May 7, 2025

this should be the other way round? deprecated fn is constructAuthorizationUrl.

so i think we should make the params of the old function work with the new one -

  • the old one doesn't even need to support new functionality (like scopes)
  • we only ever update the new function (if we do this now when we remove the deprecation we gotta move the code over to V2)
  • if a consumer wants to use /userinfo and by extension scopes , they gotta use constructAuthorizationUrlV2.

` public constructAuthorizationUrl = async (
state: string,
nonce?: string,
codeVerifier?: string,
): Promise => {

	return this.constructAuthorizationUrlV2({
		state,
		nonce,
		codeVerifier,
		userInfoScope: ["openid"]
	});
};

public constructAuthorizationUrlV2 = async (params: {
	state: string;
	userInfoScope: string[];
	nonce?: string;
	codeVerifier?: string;
}) => {

	const { state, nonce, userInfoScope, codeVerifier } = params;
	const { authorization_endpoint } = await this.getOidcConfig();
	userInfoScope.unshift("openid"); // is this needed at all if we do this?

	const queryParams = {
		state,
		...(nonce ? { nonce } : {}),
		redirect_uri: this.redirectUri,
		scope: userInfoScope.join(" "),
		client_id: this.clientID,
		response_type: "code",
		...(codeVerifier
			? { code_challenge_method: "S256", code_challenge: generators.codeChallenge(codeVerifier) }
			: {}),
	};
	const queryString = querystringUtil.stringify(queryParams);
	return `${authorization_endpoint}?${queryString}`;
};

`

@rgchua
Copy link
Collaborator

rgchua commented May 8, 2025

image

@rgchua rgchua merged commit 188c638 into master May 8, 2025
3 checks passed
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