Skip to content

Commit

Permalink
update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
KarishmaGhiya committed Oct 3, 2023
1 parent 5d48e68 commit 9c6581c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 34 deletions.
13 changes: 7 additions & 6 deletions sdk/identity/identity-brokered-auth/samples-dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
import { InteractiveBrowserCredential, useIdentityPlugin } from "@azure/identity";
import { createNativeBrokerPlugin } from "@azure/identity-brokered-auth";
import dotenv from "dotenv";
import { BrowserWindow } from 'electron';
import { BrowserWindow } from "electron";
const win = new BrowserWindow();

// Load the plugin
useIdentityPlugin(createNativeBrokerPlugin({
enableMSAPassthrough: true,
parentWindowHandle: win.getNativeWindowHandle()
}));
useIdentityPlugin(
createNativeBrokerPlugin({
enableMSAPassthrough: true,
parentWindowHandle: win.getNativeWindowHandle(),
})
);

// Load the environment
dotenv.config();
Expand All @@ -37,7 +39,6 @@ async function main() {
const token = await credential.getToken(scope);

console.log(`Token: ${token.token}: ${token.expiresOnTimestamp}`);

}

main().catch((error) => {
Expand Down
13 changes: 1 addition & 12 deletions sdk/identity/identity-brokered-auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ export function createNativeBrokerPlugin(options: NativeBrokerPluginOptions): Id
return async function nativeBrokerPlugin({ nativeBrokerPluginControl }: AzurePluginContext) {
let nativeBrokerPlugin = new NativeBrokerPlugin();
nativeBrokerPlugin.isBrokerAvailable = true;
nativeBrokerPluginControl.setNativeBroker(nativeBrokerPlugin, options)
nativeBrokerPluginControl.setNativeBroker(nativeBrokerPlugin, options);
} as IdentityPlugin;
}

// export const nativeBrokerPlugin: IdentityPlugin = (context) => {
// const { nativeBrokerPluginControl } = context as AzurePluginContext;

// nativeBrokerPluginControl.setNativeBroker(async () => new NativeBrokerPlugin());
// nativeBrokerPluginControl.createNativeBrokerPlugin(async(options?: NativeBrokerPluginOptions) => {

// return new NativeBrokerPlugin()
// }
// );
// };
8 changes: 5 additions & 3 deletions sdk/identity/identity-brokered-auth/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { useIdentityPlugin } from "@azure/identity";
import { createNativeBrokerPlugin } from "../src";

// Load the plugin
useIdentityPlugin(createNativeBrokerPlugin({
useIdentityPlugin(
createNativeBrokerPlugin({
enableMSAPassthrough: true,
parentWindowHandle: Buffer.from("dasdasd","utf-8")
}));
parentWindowHandle: Buffer.from("dasdasd", "utf-8"),
})
);
19 changes: 9 additions & 10 deletions sdk/identity/identity/src/msal/nodeFlows/msalNodeCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ export const msalNodeFlowCacheControl = {
* The current native broker provider, undefined by default.
* @internal
*/
export let nativeBrokerInfo: {
broker: msalCommon.INativeBrokerPlugin;
options: NativeBrokerPluginOptions
} | undefined = undefined;
export let nativeBrokerInfo:
| {
broker: msalCommon.INativeBrokerPlugin;
options: NativeBrokerPluginOptions;
}
| undefined = undefined;

export function hasNativeBroker(): boolean {
return nativeBrokerInfo !== undefined;
Expand All @@ -99,8 +101,8 @@ export const msalNodeFlowNativeBrokerControl: NativeBrokerPluginControl = {
setNativeBroker(broker, options): void {
nativeBrokerInfo = {
broker,
options
}
options,
};
},
};

Expand Down Expand Up @@ -282,7 +284,7 @@ export abstract class MsalNode extends MsalBaseUtilities implements MsalFlow {

if (hasNativeBroker()) {
this.msalConfig.broker = {
nativeBrokerPlugin: nativeBrokerInfo!.broker
nativeBrokerPlugin: nativeBrokerInfo!.broker,
};
}

Expand All @@ -292,9 +294,6 @@ export abstract class MsalNode extends MsalBaseUtilities implements MsalFlow {
this.app.public = new msalNode.PublicClientApplication(this.msalConfig);
}




if (this.getAssertion) {
this.msalConfig.auth.clientAssertion = await this.getAssertion();
}
Expand Down
9 changes: 6 additions & 3 deletions sdk/identity/identity/src/msal/nodeFlows/msalOpenBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ export class MsalOpenBrowser extends MsalNode {
claims: options?.claims,
correlationId: options?.correlationId,
loginHint: this.loginHint,
}
};
if (hasNativeBroker()) {
interactiveRequest.windowHandle = nativeBrokerInfo!.options.parentWindowHandle;
if (nativeBrokerInfo!.options.enableMSAPassthrough) {
(interactiveRequest.tokenQueryParameters ??= {})["msal_request_type"] = "consumer_passthrough";
(interactiveRequest.tokenQueryParameters ??= {})["msal_request_type"] =
"consumer_passthrough";
}
}
const result = await this.getApp("public", options?.enableCae).acquireTokenInteractive(interactiveRequest);
const result = await this.getApp("public", options?.enableCae).acquireTokenInteractive(
interactiveRequest
);
return this.handleResult(scopes, this.clientId, result || undefined);
} catch (err: any) {
throw this.handleError(scopes, err, options);
Expand Down

0 comments on commit 9c6581c

Please sign in to comment.