new (basic.gbapp): ALLOW ROLE keyword.
This commit is contained in:
parent
c71b616f60
commit
7a148aafaa
1 changed files with 26 additions and 23 deletions
|
@ -104,18 +104,25 @@ export class GBDeployer implements IGBDeployer {
|
||||||
* Retrives token and initialize drive client API.
|
* Retrives token and initialize drive client API.
|
||||||
*/
|
*/
|
||||||
public static async internalGetDriveClient(min: GBMinInstance) {
|
public static async internalGetDriveClient(min: GBMinInstance) {
|
||||||
const token = await (min.adminService as any)
|
let token;
|
||||||
['acquireElevatedToken'](min.instance.instanceId, true);
|
if (min['cacheToken']) {
|
||||||
const siteId = process.env.STORAGE_SITE_ID;
|
return min['cacheToken'];
|
||||||
const libraryId = process.env.STORAGE_LIBRARY;
|
} else {
|
||||||
|
token = await (min.adminService as any)['acquireElevatedToken'](min.instance.instanceId, true);
|
||||||
|
|
||||||
const client = MicrosoftGraph.Client.init({
|
const siteId = process.env.STORAGE_SITE_ID;
|
||||||
authProvider: done => {
|
const libraryId = process.env.STORAGE_LIBRARY;
|
||||||
done(null, token);
|
|
||||||
}
|
const client = MicrosoftGraph.Client.init({
|
||||||
});
|
authProvider: done => {
|
||||||
const baseUrl = `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}`;
|
done(null, token);
|
||||||
return { baseUrl, client };
|
}
|
||||||
|
});
|
||||||
|
const baseUrl = `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}`;
|
||||||
|
min['cacheToken'] = { baseUrl, client };
|
||||||
|
|
||||||
|
return min['cacheToken'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,16 +210,16 @@ export class GBDeployer implements IGBDeployer {
|
||||||
* Deploys a new blank bot to the database, cognitive services and other services.
|
* Deploys a new blank bot to the database, cognitive services and other services.
|
||||||
*/
|
*/
|
||||||
public async deployBlankBot(botId: string, mobile: string, email: string) {
|
public async deployBlankBot(botId: string, mobile: string, email: string) {
|
||||||
|
|
||||||
// Creates a new row on the GuaribasInstance table.
|
// Creates a new row on the GuaribasInstance table.
|
||||||
const instance = await this.importer.createBotInstance(botId);
|
const instance = await this.importer.createBotInstance(botId);
|
||||||
const bootInstance = GBServer.globals.bootInstance;
|
const bootInstance = GBServer.globals.bootInstance;
|
||||||
|
|
||||||
// Gets the access token to perform service operations.
|
// Gets the access token to perform service operations.
|
||||||
|
|
||||||
const accessToken = await
|
const accessToken = await (GBServer.globals.minBoot.adminService as any)['acquireElevatedToken'](
|
||||||
(GBServer.globals.minBoot.adminService as any)['acquireElevatedToken']
|
bootInstance.instanceId,
|
||||||
(bootInstance.instanceId, true);
|
true
|
||||||
|
);
|
||||||
|
|
||||||
// Creates the MSFT application that will be associated to the bot.
|
// Creates the MSFT application that will be associated to the bot.
|
||||||
|
|
||||||
|
@ -385,9 +392,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
// Connects to MSFT storage.
|
// Connects to MSFT storage.
|
||||||
|
|
||||||
const token = await
|
const token = await (min.adminService as any)['acquireElevatedToken'](min.instance.instanceId, true);
|
||||||
(min.adminService as any)['acquireElevatedToken']
|
|
||||||
(min.instance.instanceId, true);
|
|
||||||
|
|
||||||
const client = MicrosoftGraph.Client.init({
|
const client = MicrosoftGraph.Client.init({
|
||||||
authProvider: done => {
|
authProvider: done => {
|
||||||
|
@ -401,17 +406,16 @@ export class GBDeployer implements IGBDeployer {
|
||||||
const path = DialogKeywords.getGBAIPath(botId, 'gbot');
|
const path = DialogKeywords.getGBAIPath(botId, 'gbot');
|
||||||
let url = `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/root:/${path}:/children`;
|
let url = `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/root:/${path}:/children`;
|
||||||
|
|
||||||
GBLogEx.info( min ,`Loading .gbot from Excel: ${url}`);
|
GBLogEx.info(min, `Loading .gbot from Excel: ${url}`);
|
||||||
const res = await client.api(url).get();
|
const res = await client.api(url).get();
|
||||||
|
|
||||||
// Finds Config.xlsx.
|
// Finds Config.xlsx.
|
||||||
|
|
||||||
|
|
||||||
const document = res.value.filter(m => {
|
const document = res.value.filter(m => {
|
||||||
return m.name === 'Config.xlsx';
|
return m.name === 'Config.xlsx';
|
||||||
});
|
});
|
||||||
if (document === undefined || document.length === 0) {
|
if (document === undefined || document.length === 0) {
|
||||||
GBLogEx.info(min,`Config.xlsx not found on .bot folder, check the package.`);
|
GBLogEx.info(min, `Config.xlsx not found on .bot folder, check the package.`);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -446,7 +450,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
baseUrl: string = null,
|
baseUrl: string = null,
|
||||||
client = null
|
client = null
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
GBLogEx.info(min ,`downloadFolder: localPath=${localPath}, remotePath=${remotePath}, baseUrl=${baseUrl}`);
|
GBLogEx.info(min, `downloadFolder: localPath=${localPath}, remotePath=${remotePath}, baseUrl=${baseUrl}`);
|
||||||
|
|
||||||
if (!baseUrl) {
|
if (!baseUrl) {
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
@ -470,7 +474,6 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
// Retrieves all files in remote folder.
|
// Retrieves all files in remote folder.
|
||||||
|
|
||||||
|
|
||||||
let path = DialogKeywords.getGBAIPath(min.botId);
|
let path = DialogKeywords.getGBAIPath(min.botId);
|
||||||
path = urlJoin(path, remotePath);
|
path = urlJoin(path, remotePath);
|
||||||
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
||||||
|
|
Loading…
Add table
Reference in a new issue