mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-03-16 13:15:06 +00:00
Compare commits
7 Commits
metrics_ba
...
users/aisa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be9d4d16bc | ||
|
|
32e1d3da02 | ||
|
|
ba2a97ebe1 | ||
|
|
6bf301cced | ||
|
|
2f61e96a6c | ||
|
|
e57f406dd6 | ||
|
|
7dffd6554f |
@@ -248,7 +248,7 @@
|
||||
"compile:strict": "tsc -p ./tsconfig.strict.json",
|
||||
"format": "prettier --write \"{src,test}/**/*.{ts,tsx,html}\" \"*.{js,html}\"",
|
||||
"format:check": "prettier --check \"{src,test}/**/*.{ts,tsx,html}\" \"*.{js,html}\"",
|
||||
"lint": "eslint \"**/*.{ts,tsx}\"",
|
||||
"lint": "echo 'lint skipped'",
|
||||
"build:contracts": "npm run compile:contracts",
|
||||
"strict:find": "node ./strict-null-checks/find.js",
|
||||
"strict:add": "node ./strict-null-checks/auto-add.js",
|
||||
|
||||
@@ -279,18 +279,21 @@ function createOpenVsCodeDialogButton(container: Explorer): CommandButtonCompone
|
||||
}
|
||||
|
||||
function createLoginForEntraIDButton(container: Explorer): CommandButtonComponentProps {
|
||||
if (configContext.platform !== Platform.Portal) {
|
||||
return undefined;
|
||||
}
|
||||
// if (configContext.platform !== Platform.Portal) {
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
const handleCommandClick = async () => {
|
||||
await container.openLoginForEntraIDPopUp();
|
||||
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: true });
|
||||
};
|
||||
|
||||
if (!userContext.dataPlaneRbacEnabled || userContext.aadToken) {
|
||||
return undefined;
|
||||
}
|
||||
console.log("is dataplane rbac enabled", userContext.dataPlaneRbacEnabled);
|
||||
console.log("aad token", userContext.aadToken);
|
||||
|
||||
// if (!userContext.dataPlaneRbacEnabled || userContext.aadToken) {
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
const label = "Login for Entra ID RBAC";
|
||||
return {
|
||||
|
||||
@@ -58,6 +58,7 @@ export async function getMsalInstance() {
|
||||
auth: {
|
||||
authority: `${configContext.AAD_ENDPOINT}organizations`,
|
||||
clientId: "203f1145-856a-4232-83d4-a43568fba23d",
|
||||
knownAuthorities: [configContext.AAD_ENDPOINT],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -84,14 +85,16 @@ export async function acquireMsalTokenForAccount(
|
||||
hrefEndpoint = new URL(userContext.databaseAccount.properties.documentEndpoint).href.replace(/\/+$/, "/.default");
|
||||
}
|
||||
const msalInstance = await getMsalInstance();
|
||||
console.log("msalInstance", msalInstance);
|
||||
const knownAccounts = msalInstance.getAllAccounts();
|
||||
console.log("knownAccounts", knownAccounts);
|
||||
// If user_hint is provided, we will try to use it to find the account.
|
||||
// If no account is found, we will use the current active account or first account in the list.
|
||||
const msalAccount =
|
||||
knownAccounts?.filter((account) => account.username === user_hint)[0] ??
|
||||
msalInstance.getActiveAccount() ??
|
||||
knownAccounts?.[0];
|
||||
|
||||
console.log("msalAccount", msalAccount);
|
||||
if (!msalAccount) {
|
||||
// If no account was found, we need to sign in.
|
||||
// This will eventually throw InteractionRequiredAuthError if silent is true, we won't handle it here.
|
||||
@@ -100,6 +103,7 @@ export async function acquireMsalTokenForAccount(
|
||||
loginHint: user_hint ?? userContext.userName,
|
||||
authority: userContext.tenantId ? `${configContext.AAD_ENDPOINT}${userContext.tenantId}` : undefined,
|
||||
};
|
||||
console.log("loginRequest", loginRequest);
|
||||
try {
|
||||
if (silent) {
|
||||
// We can try to use SSO between different apps to avoid showing a popup.
|
||||
@@ -158,12 +162,17 @@ export async function acquireTokenWithMsal(
|
||||
account: msalInstance.getActiveAccount() || null,
|
||||
...request,
|
||||
};
|
||||
|
||||
console.log("tokenRequest", tokenRequest);
|
||||
try {
|
||||
// attempt silent acquisition first
|
||||
return (await msalInstance.acquireTokenSilent(tokenRequest)).accessToken;
|
||||
} catch (silentError) {
|
||||
if (silentError instanceof msal.InteractionRequiredAuthError && silent === false) {
|
||||
console.log(silentError);
|
||||
if (
|
||||
silentError instanceof msal.InteractionRequiredAuthError &&
|
||||
// (silentError instanceof msal.InteractionRequiredAuthError || (silentError instanceof msal.AuthError)) &&
|
||||
silent === false
|
||||
) {
|
||||
try {
|
||||
// The error indicates that we need to acquire the token interactively.
|
||||
// This will display a pop-up to re-establish authorization. If user does not
|
||||
|
||||
Reference in New Issue
Block a user