mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Introduce AAD interactive auth mode (#1860)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Contracts;
|
||||
using static Microsoft.SqlTools.Shared.Utility.Constants;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
{
|
||||
@@ -50,7 +51,7 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
CategoryValues = new CategoryValue[]
|
||||
{ new CategoryValue { DisplayName = "SQL Login", Name = "SqlLogin" },
|
||||
new CategoryValue { DisplayName = "Windows Authentication", Name = "Integrated" },
|
||||
new CategoryValue { DisplayName = "Azure Active Directory - Universal with MFA support", Name = "AzureMFA" }
|
||||
new CategoryValue { DisplayName = "Azure Active Directory - Universal with MFA support", Name = AzureMFA }
|
||||
},
|
||||
IsIdentity = true,
|
||||
IsRequired = true,
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Diagnostics;
|
||||
using Microsoft.Kusto.ServiceLayer.DataSource;
|
||||
using Microsoft.Kusto.ServiceLayer.DataSource.Metadata;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
|
||||
using static Microsoft.SqlTools.Shared.Utility.Constants;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
{
|
||||
@@ -916,7 +917,7 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
return new ConnectionDetails
|
||||
{
|
||||
ApplicationName = builder.ApplicationNameForTracing,
|
||||
AuthenticationType = "AzureMFA",
|
||||
AuthenticationType = AzureMFA,
|
||||
DatabaseName = builder.InitialCatalog,
|
||||
ServerName = builder.DataSource,
|
||||
UserName = builder.UserID,
|
||||
|
||||
@@ -20,6 +20,7 @@ using Microsoft.Kusto.ServiceLayer.LanguageServices;
|
||||
using Microsoft.Kusto.ServiceLayer.Utility;
|
||||
using Microsoft.Kusto.ServiceLayer.Workspace.Contracts;
|
||||
using CompletionItem = Microsoft.Kusto.ServiceLayer.LanguageServices.Contracts.CompletionItem;
|
||||
using static Microsoft.SqlTools.Shared.Utility.Constants;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.DataSource
|
||||
{
|
||||
@@ -63,7 +64,7 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
|
||||
|
||||
private DataSourceConnectionDetails MapKustoConnectionDetails(ConnectionDetails connectionDetails)
|
||||
{
|
||||
if (connectionDetails.AuthenticationType == "dstsAuth" || connectionDetails.AuthenticationType == "AzureMFA")
|
||||
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)}");
|
||||
|
||||
@@ -21,6 +21,7 @@ using Kusto.Language.Editor;
|
||||
using Microsoft.Kusto.ServiceLayer.Connection;
|
||||
using Microsoft.Kusto.ServiceLayer.DataSource.Contracts;
|
||||
using Microsoft.Kusto.ServiceLayer.Utility;
|
||||
using static Microsoft.SqlTools.Shared.Utility.Constants;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.DataSource.Kusto
|
||||
{
|
||||
@@ -74,7 +75,7 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource.Kusto
|
||||
ServerName = ClusterName,
|
||||
DatabaseName = DatabaseName,
|
||||
UserToken = accountToken,
|
||||
AuthenticationType = "AzureMFA"
|
||||
AuthenticationType = AzureMFA
|
||||
};
|
||||
|
||||
Initialize(connectionDetails);
|
||||
@@ -96,8 +97,8 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource.Kusto
|
||||
|
||||
switch (connectionDetails.AuthenticationType)
|
||||
{
|
||||
case "AzureMFA": return stringBuilder.WithAadUserTokenAuthentication(connectionDetails.UserToken);
|
||||
case "dstsAuth": return stringBuilder.WithDstsUserTokenAuthentication(connectionDetails.UserToken);
|
||||
case AzureMFA: return stringBuilder.WithAadUserTokenAuthentication(connectionDetails.UserToken);
|
||||
case dstsAuth: return stringBuilder.WithDstsUserTokenAuthentication(connectionDetails.UserToken);
|
||||
default:
|
||||
return string.IsNullOrWhiteSpace(connectionDetails.UserName) && string.IsNullOrWhiteSpace(connectionDetails.Password)
|
||||
? stringBuilder
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<ProjectReference Include="../Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />
|
||||
<ProjectReference Include="../Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj" />
|
||||
<ProjectReference Include="../Microsoft.SqlTools.ManagedBatchParser/Microsoft.SqlTools.ManagedBatchParser.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.SqlTools.Shared\Microsoft.SqlTools.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ObjectExplorer\DataSourceModel\TreeNodeDefinition.xml" />
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Microsoft.Kusto.ServiceLayer
|
||||
logFilePath = Logger.GenerateLogFilePath("kustoservice");
|
||||
}
|
||||
|
||||
Logger.Initialize(tracingLevel: commandOptions.TracingLevel, logFilePath: logFilePath, traceSource: "kustoservice", commandOptions.AutoFlushLog);
|
||||
Logger.Initialize(tracingLevel: commandOptions.TracingLevel, piiEnabled: commandOptions.PiiLogging, logFilePath: logFilePath, traceSource: "kustoservice", commandOptions.AutoFlushLog);
|
||||
|
||||
// set up the host details and profile paths
|
||||
var hostDetails = new HostDetails(version: new Version(1, 0));
|
||||
|
||||
Reference in New Issue
Block a user