From 9e1fc421a4ae5568e6393f6888d764de8d1914f7 Mon Sep 17 00:00:00 2001 From: Richard Orilla Date: Mon, 17 Oct 2022 15:33:30 +0800 Subject: [PATCH 1/3] Added support for parsing authentication along with utilizing active directory access token and service principals --- lib/base/connection-pool.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/base/connection-pool.js b/lib/base/connection-pool.js index eb468f2e..527ff045 100644 --- a/lib/base/connection-pool.js +++ b/lib/base/connection-pool.js @@ -114,6 +114,9 @@ class ConnectionPool extends EventEmitter { case 'attachdbfilename': break case 'authentication': + Object.assign(config.authentication, { + type: value + }) break case 'column encryption setting': break @@ -133,6 +136,16 @@ class ConnectionPool extends EventEmitter { break case 'context connection': break + case 'client id': + Object.assign(config.authentication.options, { + clientId: value + }) + break + case 'client secret': + Object.assign(config.authentication.options, { + clientSecret: value + }) + break case 'current language': Object.assign(config.options, { language: value @@ -222,6 +235,16 @@ class ConnectionPool extends EventEmitter { break case 'replication': break + case 'tenant id': + Object.assign(config.authentication.options, { + tenantId: value + }) + break + case 'token': + Object.assign(config.authentication.options, { + token: value + }) + break case 'transaction binding': Object.assign(config.options, { enableImplicitTransactions: value.toLowerCase() === 'implicit unbind' @@ -278,7 +301,7 @@ class ConnectionPool extends EventEmitter { break } return config - }, { options: {}, pool: {} }) + }, { authentication: { options: {} }, options: {}, pool: {} }) } /** From 03111627afbb15dc55a0044ac6315ff1ca4c7eee Mon Sep 17 00:00:00 2001 From: Richard Orilla Date: Fri, 28 Oct 2022 17:39:35 +0800 Subject: [PATCH 2/3] Updated readme.md, added azure active directory configurations in the formats example --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a763c61..2d752227 100644 --- a/README.md +++ b/README.md @@ -571,12 +571,36 @@ Complete list of pool options can be found [here](https://github.com/vincit/tarn In addition to configuration object there is an option to pass config as a connection string. Connection strings are supported. ##### Classic Connection String +###### Standard configuration using tedious driver ``` Server=localhost,1433;Database=database;User Id=username;Password=password;Encrypt=true +``` +###### Standard configuration using msnodesqlv8 driver +``` Driver=msnodesqlv8;Server=(local)\INSTANCE;Database=database;UID=DOMAIN\username;PWD=password;Encrypt=true ``` +##### Azure Active Directory Authentication Connection String + +Several types of Azure Authentication are supported: +###### Authentication using Default Azure Credentials +``` +Server=*.database.windows.net;Database=database;Authentication=azure-active-directory-default;ClientID=clientid;Encrypt=true +``` +###### Authentication using Active Directory Password +``` +Server=*.database.windows.net;Database=database;Authentication=azure-active-directory-password;User Id=username;Password=password;ClientID=clientid;TenantID=tenantid;Encrypt=true +``` +###### Authentication using Access Token +``` +Server=*.database.windows.net;Database=database;Authentication=azure-active-directory-access-token;Token=token;Encrypt=true +``` +###### Authentication using Service Principal +``` +Server=*.database.windows.net;Database=database;Authentication=azure-active-directory-service-principal-secret;ClientID=clientid;ClientSecret=clientsecret;TenantID=tenantid;Encrypt=true +``` + ## Drivers ### Tedious @@ -2097,4 +2121,4 @@ to create new connections or not [appveyor-url]: https://ci.appveyor.com/project/tediousjs/node-mssql [tedious-url]: https://www.npmjs.com/package/tedious -[msnodesqlv8-url]: https://www.npmjs.com/package/msnodesqlv8 +[msnodesqlv8-url]: https://www.npmjs.com/package/msnodesqlv8 \ No newline at end of file From 9f81f18cf47c0c71283240040a6fb79536751127 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Mon, 31 Oct 2022 15:22:49 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e0d532ed..438b8f7f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,7 @@ +v9.?.? (2022-??-??) +------------------- +[new] Add support for AAD authentication via connection string ((#1436)[https://github.com/tediousjs/node-mssql/pull/1436]) + v9.0.1 (2022-08-18) ------------------- [fix] fix regression in requestTimout option not accepting `0` as a value ([#1421](https://github.com/tediousjs/node-mssql/pull/1421))