mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-21 17:24:03 -05:00
Add login management handlers (#1868)
* update contracts * finish creating/loading login for SQL Server * support role read for azure and add more handlers * fix advanced option flags --------- Co-authored-by: Karl Burtram <karlb@microsoft.com>
This commit is contained in:
@@ -12,14 +12,24 @@ using Newtonsoft.Json.Converters;
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum LoginType
|
||||
public enum LoginAuthenticationType
|
||||
{
|
||||
[EnumMember(Value = "Windows")]
|
||||
Windows,
|
||||
[EnumMember(Value = "Sql")]
|
||||
Sql,
|
||||
[EnumMember(Value = "AAD")]
|
||||
AzureActiveDirectory
|
||||
AAD,
|
||||
[EnumMember(Value = "Others")]
|
||||
Others
|
||||
}
|
||||
|
||||
public class ServerLoginDatabaseUserMapping
|
||||
{
|
||||
public string Database { get; set; }
|
||||
public string User { get; set; }
|
||||
public string DefaultSchema { get; set; }
|
||||
public string[] DatabaseRoles { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -27,27 +37,22 @@ namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
/// </summary>
|
||||
public class LoginInfo
|
||||
{
|
||||
public string LoginName { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public LoginType LoginType { get; set; }
|
||||
|
||||
public string CertificateName { get; set; }
|
||||
|
||||
public string AsymmetricKeyName { get; set; }
|
||||
public LoginAuthenticationType AuthenticationType { get; set; }
|
||||
|
||||
public bool WindowsGrantAccess { get; set; }
|
||||
|
||||
public bool MustChange { get; set; }
|
||||
public bool MustChangePassword { get; set; }
|
||||
|
||||
public bool IsDisabled { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
public bool ConnectPermission { get; set; }
|
||||
|
||||
public bool IsLockedOut { get; set; }
|
||||
|
||||
public bool EnforcePolicy { get; set; }
|
||||
public bool EnforcePasswordPolicy { get; set; }
|
||||
|
||||
public bool EnforceExpiration { get; set; }
|
||||
|
||||
public bool WindowsAuthSupported { get; set; }
|
||||
public bool EnforcePasswordExpiration { get; set; }
|
||||
|
||||
public string Password { get; set; }
|
||||
|
||||
@@ -56,5 +61,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
public string DefaultLanguage { get; set; }
|
||||
|
||||
public string DefaultDatabase { get; set; }
|
||||
|
||||
public string[] ServerRoles {get; set;}
|
||||
|
||||
public ServerLoginDatabaseUserMapping[] UserMapping;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
@@ -16,20 +15,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
/// </summary>
|
||||
public class CreateLoginParams : GeneralRequestDetails
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
public string ContextId { get; set; }
|
||||
|
||||
public LoginInfo Login { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create Login result
|
||||
/// </summary>
|
||||
public class CreateLoginResult : ResultStatus
|
||||
{
|
||||
public LoginInfo Login { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create Login request type
|
||||
/// </summary>
|
||||
@@ -39,8 +29,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<CreateLoginParams, CreateLoginResult> Type =
|
||||
RequestType<CreateLoginParams, CreateLoginResult>.Create("security/createlogin");
|
||||
RequestType<CreateLoginParams, object> Type =
|
||||
RequestType<CreateLoginParams, object>.Create("objectManagement/createLogin");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,9 +38,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
/// </summary>
|
||||
public class DeleteLoginParams : GeneralRequestDetails
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
public string ConnectionUri { get; set; }
|
||||
|
||||
public string LoginName { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,7 +52,78 @@ namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<DeleteLoginParams, ResultStatus> Type =
|
||||
RequestType<DeleteLoginParams, ResultStatus>.Create("security/deletelogin");
|
||||
RequestType<DeleteLoginParams, object> Type =
|
||||
RequestType<DeleteLoginParams, object>.Create("objectManagement/deleteLogin");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Login params
|
||||
/// </summary>
|
||||
public class UpdateLoginParams : GeneralRequestDetails
|
||||
{
|
||||
public string ContextId { get; set; }
|
||||
|
||||
public LoginInfo Login { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Login request type
|
||||
/// </summary>
|
||||
public class UpdateLoginRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<UpdateLoginParams, object> Type =
|
||||
RequestType<UpdateLoginParams, object>.Create("objectManagement/updateLogin");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update Login params
|
||||
/// </summary>
|
||||
public class DisposeLoginViewRequestParams : GeneralRequestDetails
|
||||
{
|
||||
public string ContextId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Login request type
|
||||
/// </summary>
|
||||
public class DisposeLoginViewRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<DisposeLoginViewRequestParams, object> Type =
|
||||
RequestType<DisposeLoginViewRequestParams, object>.Create("objectManagement/disposeLoginView");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize Login View Request params
|
||||
/// </summary>
|
||||
|
||||
public class InitializeLoginViewRequestParams : GeneralRequestDetails
|
||||
{
|
||||
public string ConnectionUri { get; set; }
|
||||
public string ContextId { get; set; }
|
||||
public bool IsNewObject { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize Login View request type
|
||||
/// </summary>
|
||||
public class InitializeLoginViewRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<InitializeLoginViewRequestParams, LoginViewInfo> Type =
|
||||
RequestType<InitializeLoginViewRequestParams, LoginViewInfo>.Create("objectManagement/initializeLoginView");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Security.Contracts
|
||||
{
|
||||
public class LoginViewInfo
|
||||
{
|
||||
|
||||
public LoginInfo ObjectInfo { get; set; }
|
||||
public bool SupportWindowsAuthentication { get; set; }
|
||||
public bool SupportAADAuthentication { get; set; }
|
||||
public bool SupportSQLAuthentication { get; set; }
|
||||
public bool CanEditLockedOutState { get; set; }
|
||||
public string[] Databases;
|
||||
public string[] Languages;
|
||||
public string[] ServerRoles;
|
||||
public bool SupportAdvancedPasswordOptions;
|
||||
public bool SupportAdvancedOptions;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user