mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-15 07:43:27 +00:00
added gsuite type and secret config
This commit is contained in:
@@ -315,6 +315,15 @@ namespace Bit.Console
|
|||||||
config.Azure.Tenant = parameters["t"];
|
config.Azure.Tenant = parameters["t"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(config.Type == Core.Enums.DirectoryType.GSuite)
|
||||||
|
{
|
||||||
|
config.GSuite = new GSuiteConfiguration();
|
||||||
|
|
||||||
|
if(parameters.ContainsKey("f"))
|
||||||
|
{
|
||||||
|
config.GSuite.SecretFile = parameters["f"];
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
config.Ldap = config.Ldap ?? new LdapConfiguration();
|
config.Ldap = config.Ldap ?? new LdapConfiguration();
|
||||||
@@ -358,7 +367,8 @@ namespace Bit.Console
|
|||||||
|
|
||||||
Con.WriteLine("1. Active Directory");
|
Con.WriteLine("1. Active Directory");
|
||||||
Con.WriteLine("2. Azure Active Directory ");
|
Con.WriteLine("2. Azure Active Directory ");
|
||||||
Con.WriteLine("3. Other LDAP Directory");
|
Con.WriteLine("3. GSuite Directory");
|
||||||
|
Con.WriteLine("4. Other LDAP Directory");
|
||||||
|
|
||||||
string currentType;
|
string currentType;
|
||||||
switch(config.Type)
|
switch(config.Type)
|
||||||
@@ -369,9 +379,12 @@ namespace Bit.Console
|
|||||||
case Core.Enums.DirectoryType.AzureActiveDirectory:
|
case Core.Enums.DirectoryType.AzureActiveDirectory:
|
||||||
currentType = "2";
|
currentType = "2";
|
||||||
break;
|
break;
|
||||||
default:
|
case Core.Enums.DirectoryType.GSuite:
|
||||||
currentType = "3";
|
currentType = "3";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
currentType = "4";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Con.WriteLine();
|
Con.WriteLine();
|
||||||
Con.Write("Type [{0}]: ", currentType);
|
Con.Write("Type [{0}]: ", currentType);
|
||||||
@@ -386,6 +399,9 @@ namespace Bit.Console
|
|||||||
case "2":
|
case "2":
|
||||||
config.Type = Core.Enums.DirectoryType.AzureActiveDirectory;
|
config.Type = Core.Enums.DirectoryType.AzureActiveDirectory;
|
||||||
break;
|
break;
|
||||||
|
case "3":
|
||||||
|
config.Type = Core.Enums.DirectoryType.GSuite;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
config.Type = Core.Enums.DirectoryType.Other;
|
config.Type = Core.Enums.DirectoryType.Other;
|
||||||
break;
|
break;
|
||||||
@@ -416,6 +432,17 @@ namespace Bit.Console
|
|||||||
input = null;
|
input = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(config.Type == Core.Enums.DirectoryType.GSuite)
|
||||||
|
{
|
||||||
|
config.GSuite = config.GSuite ?? new GSuiteConfiguration();
|
||||||
|
|
||||||
|
Con.Write("Secret file [{0}]: ", config.GSuite.SecretFile);
|
||||||
|
input = Con.ReadLine();
|
||||||
|
if(!string.IsNullOrEmpty(input))
|
||||||
|
{
|
||||||
|
config.GSuite.SecretFile = input.Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
config.Ldap = config.Ldap ?? new LdapConfiguration();
|
config.Ldap = config.Ldap ?? new LdapConfiguration();
|
||||||
@@ -523,7 +550,8 @@ namespace Bit.Console
|
|||||||
|
|
||||||
config.RemoveDisabledUsers = parameters.ContainsKey("rd");
|
config.RemoveDisabledUsers = parameters.ContainsKey("rd");
|
||||||
|
|
||||||
if(SettingsService.Instance.Server.Type != Core.Enums.DirectoryType.AzureActiveDirectory)
|
if(SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.ActiveDirectory ||
|
||||||
|
SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.Other)
|
||||||
{
|
{
|
||||||
if(parameters.ContainsKey("go"))
|
if(parameters.ContainsKey("go"))
|
||||||
{
|
{
|
||||||
@@ -593,8 +621,8 @@ namespace Bit.Console
|
|||||||
{
|
{
|
||||||
config.SyncGroups = input == "y" || input == "yes";
|
config.SyncGroups = input == "y" || input == "yes";
|
||||||
}
|
}
|
||||||
if(config.SyncGroups &&
|
if(config.SyncGroups && (SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.ActiveDirectory ||
|
||||||
SettingsService.Instance.Server.Type != Core.Enums.DirectoryType.AzureActiveDirectory)
|
SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.Other))
|
||||||
{
|
{
|
||||||
Con.Write("Group path [{0}]: ", config.Ldap.GroupPath);
|
Con.Write("Group path [{0}]: ", config.Ldap.GroupPath);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
@@ -628,8 +656,8 @@ namespace Bit.Console
|
|||||||
{
|
{
|
||||||
config.SyncUsers = input == "y" || input == "yes";
|
config.SyncUsers = input == "y" || input == "yes";
|
||||||
}
|
}
|
||||||
if(config.SyncUsers &&
|
if(config.SyncUsers && (SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.ActiveDirectory ||
|
||||||
SettingsService.Instance.Server.Type != Core.Enums.DirectoryType.AzureActiveDirectory)
|
SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.Other))
|
||||||
{
|
{
|
||||||
Con.Write("User path [{0}]: ", config.Ldap.UserPath);
|
Con.Write("User path [{0}]: ", config.Ldap.UserPath);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
@@ -680,7 +708,8 @@ namespace Bit.Console
|
|||||||
config.UserFilter = input;
|
config.UserFilter = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SettingsService.Instance.Server.Type != Core.Enums.DirectoryType.AzureActiveDirectory)
|
if(SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.ActiveDirectory ||
|
||||||
|
SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.Other)
|
||||||
{
|
{
|
||||||
Con.Write("Member Attribute [{0}]: ", config.Ldap.MemberAttribute);
|
Con.Write("Member Attribute [{0}]: ", config.Ldap.MemberAttribute);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
@@ -753,7 +782,7 @@ namespace Bit.Console
|
|||||||
|
|
||||||
if(result.Success)
|
if(result.Success)
|
||||||
{
|
{
|
||||||
WriteSuccessLine(string.Format("Syncing complete ({0} users, {1} groups).",
|
WriteSuccessLine(string.Format("Syncing complete ({0} users, {1} groups).",
|
||||||
result.Users.Count, result.Groups.Count));
|
result.Users.Count, result.Groups.Count));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -90,6 +90,7 @@
|
|||||||
<Compile Include="Models\ApiError.cs" />
|
<Compile Include="Models\ApiError.cs" />
|
||||||
<Compile Include="Models\ApiResult.cs" />
|
<Compile Include="Models\ApiResult.cs" />
|
||||||
<Compile Include="Models\Entry.cs" />
|
<Compile Include="Models\Entry.cs" />
|
||||||
|
<Compile Include="Models\GSuiteConfiguration.cs" />
|
||||||
<Compile Include="Models\ImportRequest.cs" />
|
<Compile Include="Models\ImportRequest.cs" />
|
||||||
<Compile Include="Models\AzureConfiguration.cs" />
|
<Compile Include="Models\AzureConfiguration.cs" />
|
||||||
<Compile Include="Models\ServerConfiguration.cs" />
|
<Compile Include="Models\ServerConfiguration.cs" />
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Bit.Core.Enums
|
|||||||
{
|
{
|
||||||
ActiveDirectory = 0,
|
ActiveDirectory = 0,
|
||||||
AzureActiveDirectory = 1,
|
AzureActiveDirectory = 1,
|
||||||
Other = 2
|
Other = 2,
|
||||||
|
GSuite = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/Core/Models/GSuiteConfiguration.cs
Normal file
7
src/Core/Models/GSuiteConfiguration.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Bit.Core.Models
|
||||||
|
{
|
||||||
|
public class GSuiteConfiguration
|
||||||
|
{
|
||||||
|
public string SecretFile { get; set; } = "client_secret.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,5 +13,6 @@ namespace Bit.Core.Models
|
|||||||
public Enums.DirectoryType Type { get; set; } = Enums.DirectoryType.ActiveDirectory;
|
public Enums.DirectoryType Type { get; set; } = Enums.DirectoryType.ActiveDirectory;
|
||||||
public LdapConfiguration Ldap { get; set; }
|
public LdapConfiguration Ldap { get; set; }
|
||||||
public AzureConfiguration Azure { get; set; }
|
public AzureConfiguration Azure { get; set; }
|
||||||
|
public GSuiteConfiguration GSuite { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ namespace Bit.Core.Models
|
|||||||
case DirectoryType.ActiveDirectory:
|
case DirectoryType.ActiveDirectory:
|
||||||
break;
|
break;
|
||||||
case DirectoryType.AzureActiveDirectory:
|
case DirectoryType.AzureActiveDirectory:
|
||||||
GroupFilter = null;
|
|
||||||
UserFilter = null;
|
|
||||||
break;
|
break;
|
||||||
case DirectoryType.Other:
|
case DirectoryType.Other:
|
||||||
IntervalMinutes = 60;
|
IntervalMinutes = 60;
|
||||||
|
|||||||
Reference in New Issue
Block a user