mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-16 17:23:38 -05:00
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:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user