Skip to content

Commit

Permalink
- Add embeddedClientId to native request.
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantin-msft committed Oct 3, 2024
1 parent be76dda commit 986828d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/msal-browser/src/broker/nativeBroker/NativeRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type NativeTokenRequest = {
extraParameters?: StringDict;
storeInCache?: StoreInCache; // Object of booleans indicating whether to store tokens in the cache or not (default is true)
signPopToken?: boolean; // Set to true only if token request deos not contain a PoP keyId
embeddedClientId?: string;
};

/**
Expand Down
38 changes: 32 additions & 6 deletions lib/msal-browser/src/interaction_client/NativeInteractionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,18 +1043,36 @@ export class NativeInteractionClient extends BaseInteractionClient {
return;
}

if (
const hasExtraBrokerParams =
request.extraParameters &&
request.extraParameters.hasOwnProperty(
AADServerParamKeys.BROKER_CLIENT_ID
) &&
request.extraParameters.hasOwnProperty(
AADServerParamKeys.BROKER_REDIRECT_URI
) &&
request.extraParameters.hasOwnProperty(AADServerParamKeys.CLIENT_ID)
) {
const child_client_id =
request.extraParameters[AADServerParamKeys.CLIENT_ID];
const child_redirect_uri = request.redirectUri;
request.extraParameters.hasOwnProperty(
AADServerParamKeys.CLIENT_ID
);

if (!request.embeddedClientId && !hasExtraBrokerParams) {
return;
}

const child_client_id =
request.extraParameters[AADServerParamKeys.CLIENT_ID];
const child_redirect_uri = request.redirectUri;

if (request.embeddedClientId) {
request.extraParameters = {
[AADServerParamKeys.BROKER_CLIENT_ID]:
this.config.auth.clientId,
[AADServerParamKeys.BROKER_REDIRECT_URI]:
this.config.auth.redirectUri,
child_client_id,
child_redirect_uri,
};
} else if (hasExtraBrokerParams) {
const brk_redirect_uri =
request.extraParameters[AADServerParamKeys.BROKER_REDIRECT_URI];
request.extraParameters = {
Expand All @@ -1063,5 +1081,13 @@ export class NativeInteractionClient extends BaseInteractionClient {
};
request.redirectUri = brk_redirect_uri;
}

this.performanceClient?.addFields(
{
embeddedClientId: child_client_id,
embeddedRedirectUri: child_redirect_uri,
},
request.correlationId
);
}
}

0 comments on commit 986828d

Please sign in to comment.