Reinstate get authorization token path which doesn't get called every 5 minutes anymore

This commit is contained in:
Laurent Nguyen 2024-05-23 17:11:03 +02:00
parent 0a8e3736dd
commit a3f3511043
1 changed files with 11 additions and 18 deletions

View File

@ -1,6 +1,7 @@
import * as Cosmos from "@azure/cosmos"; import * as Cosmos from "@azure/cosmos";
import { sendCachedDataMessage } from "Common/MessageHandler";
import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizationTokenUsingResourceTokens"; import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizationTokenUsingResourceTokens";
import { AuthorizationToken } from "Contracts/FabricMessageTypes"; import { AuthorizationToken, FabricMessageTypes } from "Contracts/FabricMessageTypes";
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil"; import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility"; import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
import { AuthType } from "../AuthType"; import { AuthType } from "../AuthType";
@ -50,23 +51,15 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
case Cosmos.ResourceType.offer: case Cosmos.ResourceType.offer:
case Cosmos.ResourceType.user: case Cosmos.ResourceType.user:
case Cosmos.ResourceType.permission: case Cosmos.ResourceType.permission:
// For now, these operations aren't used, so fetching the authorization token is commented out. // User master tokens
// This provider must return a real token to pass validation by the client, so we return the cached resource token const authorizationToken = await sendCachedDataMessage<AuthorizationToken>(
// (which is a valid token, but won't work for these operations). FabricMessageTypes.GetAuthorizationToken,
const resourceTokens2 = userContext.fabricContext.databaseConnectionInfo.resourceTokens; [requestInfo],
return getAuthorizationTokenUsingResourceTokens(resourceTokens2, requestInfo.path, requestInfo.resourceId); userContext.fabricContext.connectionId,
);
/* ************** TODO: Uncomment this code if we need to support these operations ************** console.log("Response from Fabric: ", authorizationToken);
// User master tokens headers[HttpHeaders.msDate] = authorizationToken.XDate;
const authorizationToken = await sendCachedDataMessage<AuthorizationToken>( return decodeURIComponent(authorizationToken.PrimaryReadWriteToken);
FabricMessageTypes.GetAuthorizationToken,
[requestInfo],
userContext.fabricContext.connectionId,
);
console.log("Response from Fabric: ", authorizationToken);
headers[HttpHeaders.msDate] = authorizationToken.XDate;
return decodeURIComponent(authorizationToken.PrimaryReadWriteToken);
***********************************************************************************************/
} }
} }