From b3709e89a7198ef6588692722ed04fa7ecfb0ee0 Mon Sep 17 00:00:00 2001 From: Ohad Bitton Date: Thu, 10 Nov 2022 20:59:11 +0200 Subject: [PATCH] revert delete user password --- packages/azure-kusto-data/index.html | 346 ------------------ packages/azure-kusto-data/src/models.ts | 2 +- packages/azure-kusto-data/src/security.ts | 4 +- .../azure-kusto-data/src/tokenProvider.ts | 28 +- packages/azure-kusto-data/webpack.config.ts | 20 - packages/azure-kusto-ingest/package.json | 11 +- packages/azure-kusto-ingest/webpack.config.ts | 21 +- 7 files changed, 39 insertions(+), 393 deletions(-) delete mode 100644 packages/azure-kusto-data/index.html diff --git a/packages/azure-kusto-data/index.html b/packages/azure-kusto-data/index.html deleted file mode 100644 index ab1123b..0000000 --- a/packages/azure-kusto-data/index.html +++ /dev/null @@ -1,346 +0,0 @@ - - - - - Carved Rock Fitness - - - - - - - - - - - - -
- - - - - - - -
-
-

GET A GRIP

-

20% OFF

-

THROUGHOUT THE SEASON

-
-
- - -
-
-
- Brown Boots -
-
Couples retreat weekend
-
Save an extra 20%
-
when you buy 2 pairs of boots
-
- Grey Boots -
-
-
- - -
- -
- - -
-
-
-
-

Trail Review

-
-
-

Trail Review

-
Asphalt
-
National Park
- See Review -
-
-
-
- - - -
- - - diff --git a/packages/azure-kusto-data/src/models.ts b/packages/azure-kusto-data/src/models.ts index 7d30607..2ef7de8 100644 --- a/packages/azure-kusto-data/src/models.ts +++ b/packages/azure-kusto-data/src/models.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import moment from 'moment' +import moment from "moment" export enum WellKnownDataSet { PrimaryResult = "PrimaryResult", diff --git a/packages/azure-kusto-data/src/security.ts b/packages/azure-kusto-data/src/security.ts index 402fd4f..5010f3b 100644 --- a/packages/azure-kusto-data/src/security.ts +++ b/packages/azure-kusto-data/src/security.ts @@ -13,7 +13,9 @@ export class AadHelper { throw new Error("Invalid string builder - missing dataSource"); } - if (!!kcsb.applicationClientId && !!kcsb.applicationKey) { + if (!!kcsb.aadUserId && !!kcsb.password) { + this.tokenProvider = new TokenProvider.UserPassTokenProvider(kcsb.dataSource, kcsb.aadUserId, kcsb.password, kcsb.authorityId); + } else if (!!kcsb.applicationClientId && !!kcsb.applicationKey) { this.tokenProvider = new TokenProvider.ApplicationKeyTokenProvider( kcsb.dataSource, kcsb.applicationClientId, diff --git a/packages/azure-kusto-data/src/tokenProvider.ts b/packages/azure-kusto-data/src/tokenProvider.ts index 900d1bb..cb11bf8 100644 --- a/packages/azure-kusto-data/src/tokenProvider.ts +++ b/packages/azure-kusto-data/src/tokenProvider.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { AzureCliCredential, ManagedIdentityCredential, ClientSecretCredential, ClientCertificateCredential, ClientCertificateCredentialOptions, ClientCertificatePEMCertificate, DeviceCodeCredential, DeviceCodeInfo } from "@azure/identity"; +import { AzureCliCredential, ManagedIdentityCredential, ClientSecretCredential, ClientCertificateCredential, ClientCertificateCredentialOptions, ClientCertificatePEMCertificate, DeviceCodeCredential, DeviceCodeInfo, UsernamePasswordCredential } from "@azure/identity"; import { TokenCredential } from "@azure/core-auth"; import { InteractiveBrowserCredential } from "@azure/identity"; import { CloudInfo, CloudSettings } from "./cloudSettings"; @@ -229,6 +229,32 @@ export class AzCliTokenProvider extends AzureIdentityProvider { } } +/** + * Acquire a token from MSAL with username and password + */ + export class UserPassTokenProvider extends AzureIdentityProvider { + + userName: string; + password: string; + homeAccountId?: string; + constructor(kustoUri: string, userName: string, password: string, authorityId: string) { + super(kustoUri, authorityId, undefined); + this.userName = userName; + this.password = password; + } + + getCredential(): TokenCredential { + return new UsernamePasswordCredential(this.authorityId!, this.cloudInfo.KustoClientAppId, this.userName, this.password); + } + + context(): Record { + return { + ...super.context(), + userName: this.userName, + homeAccountId: this.homeAccountId, + }; + } + } /** * Acquire a token from Device Login flow diff --git a/packages/azure-kusto-data/webpack.config.ts b/packages/azure-kusto-data/webpack.config.ts index 20183ef..6cb9d1d 100644 --- a/packages/azure-kusto-data/webpack.config.ts +++ b/packages/azure-kusto-data/webpack.config.ts @@ -4,26 +4,6 @@ import 'webpack-dev-server'; const webpack = require('webpack'); let production = process.env.NODE_ENV === "production"; -// let crypto; -// try {crypto = require.resolve("crypto-browserify") -// } catch {} - -// let assert; -// try {assert = require.resolve("assert") -// } catch {} - -// let http; -// try {http = require.resolve("stream-http") -// } catch {} - -// let crypto; -// try {crypto = require.resolve("crypto-browserify") -// } catch {} - -// let crypto; -// try {crypto = require.resolve("crypto-browserify") -// } catch {} - let config = { entry: { index: "./src/index", diff --git a/packages/azure-kusto-ingest/package.json b/packages/azure-kusto-ingest/package.json index 099df98..74d60b3 100644 --- a/packages/azure-kusto-ingest/package.json +++ b/packages/azure-kusto-ingest/package.json @@ -6,7 +6,8 @@ "module": "dist-esm/src/index.js", "types": "dist-esm/src/index.d.ts", "scripts": { - "build": "tsc" + "build": "tsc", + "webpack": "webpack serve" }, "engines": { "node": ">= 14.0.0" @@ -46,7 +47,8 @@ "https": false, "http": false, "crypto": false, - "stream": "readable-stream", + "stream": "stream-browserify", + "zlib": "browserify-zlib", "./dist-esm/src/streamUtils.js": "./dist-esm/src/streamUtils.browser.js", "./dist-esm/src/fileDescriptor.js": "./dist-esm/src/fileDescriptor.browser.js", "./dist-esm/src/ingestClient.js": "./dist-esm/src/ingestClient.browser.ts" @@ -63,13 +65,14 @@ "azure-kusto-data": "^3.4.3", "browserify-zlib": "0.2.0", "moment": "^2.29.4", - "readable-stream": "~2.1.0", "root": "file:../..", "stream-array": "^1.1.2", "stream-to-array": "^2.3.0", "tmp-promise": "^3.0.3", "uuid": "^8.3.2", - "uuid-validate": "0.0.3" + "uuid-validate": "0.0.3", + "stream-browserify": "3.0.0" + }, "gitHead": "f8a5dae26d6d2ca2ab8b95953bb9b88a02e8e35d", "devDependencies": { diff --git a/packages/azure-kusto-ingest/webpack.config.ts b/packages/azure-kusto-ingest/webpack.config.ts index 9d56f15..41f854c 100644 --- a/packages/azure-kusto-ingest/webpack.config.ts +++ b/packages/azure-kusto-ingest/webpack.config.ts @@ -14,14 +14,6 @@ let config = { filename: "[name].js", path: path.resolve(__dirname, "dist"), }, - // plugins: - // // Work around for Buffer is undefined: - // // https://github.com/webpack/changelog-v5/issues/10 - // // Required for "rhea" package - // new webpack.ProvidePlugin({ - // Buffer: ['buffer', 'Buffer'], - // }) - // , module: { rules: [ { @@ -33,18 +25,7 @@ let config = { }, resolve: { aliasFields: ['browser'], - fallback: { - crypto:require.resolve('crypto-browserify') , - assert :require.resolve('assert'), - http : require.resolve('stream-http'), - https: require.resolve('https-browserify'), - stream: require.resolve('stream-browserify'), - buffer: require.resolve('buffer'), - zlib: require.resolve('browserify-zlib'), - url: false, - "fs": false - - }, + fallback:{ "stream": require.resolve("stream-browserify")}, extensions: [".ts", ".js"], }, devtool: "inline-source-map",