Kusto NoAuth authentication (#1161)

* Added username and password to DataSourceConnectionDetails. Refactored KustoClient>GetKustoConnectionStringBuilder to accept no username or password for no credentials authentication.

* Removed invalid Unit Test and added 2 unit tests for testing authentication type.

* Added validation for dstsAuth and AzureMFA in DataSourceFactory. Added unit test for validation.
This commit is contained in:
Justin M
2021-02-23 17:29:09 -08:00
committed by GitHub
parent 294a6f4dc2
commit 13a7d4aa2b
4 changed files with 39 additions and 22 deletions

View File

@@ -8,8 +8,8 @@ using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
using Microsoft.Kusto.ServiceLayer.DataSource.Intellisense;
using Microsoft.Kusto.ServiceLayer.LanguageServices;
using Microsoft.Kusto.ServiceLayer.LanguageServices.Contracts;
using Microsoft.Kusto.ServiceLayer.Workspace.Contracts;
using Microsoft.Kusto.ServiceLayer.Utility;
using Microsoft.Kusto.ServiceLayer.Workspace.Contracts;
namespace Microsoft.Kusto.ServiceLayer.DataSource
{
@@ -18,8 +18,6 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
{
public IDataSource Create(DataSourceType dataSourceType, ConnectionDetails connectionDetails, string ownerUri)
{
ValidationUtils.IsArgumentNotNullOrWhiteSpace(connectionDetails.AccountToken, nameof(connectionDetails.AccountToken));
switch (dataSourceType)
{
case DataSourceType.Kusto:
@@ -39,13 +37,21 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
private DataSourceConnectionDetails MapKustoConnectionDetails(ConnectionDetails connectionDetails)
{
if (connectionDetails.AuthenticationType == "dstsAuth" || connectionDetails.AuthenticationType == "AzureMFA")
{
ValidationUtils.IsTrue<ArgumentException>(!string.IsNullOrWhiteSpace(connectionDetails.AccountToken),
$"The Kusto User Token is not specified - set {nameof(connectionDetails.AccountToken)}");
}
return new DataSourceConnectionDetails
{
ServerName = connectionDetails.ServerName,
DatabaseName = connectionDetails.DatabaseName,
ConnectionString = connectionDetails.ConnectionString,
AuthenticationType = connectionDetails.AuthenticationType,
UserToken = connectionDetails.AccountToken
UserToken = connectionDetails.AccountToken,
UserName = connectionDetails.UserName,
Password = connectionDetails.Password
};
}