mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Allow for changing database name (#1397)
* Remove hard coded database name * Update permissions on build scripts * Update Setup project and run scripts for configuring database name * Remove hyphen from database name flag * Update with suggested changes, still needs testing * Revert SQL statements to concatenantion for testing * Fix typo * Update util/Setup/EnvironmentFileBuilder.cs Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com> * Update SQL commands to prevent SQL injection attacks Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
This commit is contained in:
@ -149,6 +149,7 @@ namespace Bit.Setup
|
||||
public bool SelfSignedCert { get; set; }
|
||||
public string IdentityCertPassword { get; set; }
|
||||
public string Domain { get; set; }
|
||||
public string Database { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace Bit.Setup
|
||||
var dbConnectionString = new SqlConnectionStringBuilder
|
||||
{
|
||||
DataSource = "tcp:mssql,1433",
|
||||
InitialCatalog = "vault",
|
||||
InitialCatalog = _context.Install?.Database,
|
||||
UserID = "sa",
|
||||
Password = dbPassword,
|
||||
MultipleActiveResultSets = false,
|
||||
@ -75,7 +75,7 @@ namespace Bit.Setup
|
||||
_globalOverrideValues = new Dictionary<string, string>
|
||||
{
|
||||
["globalSettings__baseServiceUri__vault"] = _context.Config.Url,
|
||||
["globalSettings__sqlServer__connectionString"] = $"\"{dbConnectionString}\"",
|
||||
["globalSettings__sqlServer__connectionString"] = $"'{dbConnectionString}'",
|
||||
["globalSettings__identityServer__certificatePassword"] = _context.Install?.IdentityCertPassword,
|
||||
["globalSettings__internalIdentityKey"] = _context.Stub ? "RANDOM_IDENTITY_KEY" :
|
||||
Helpers.SecureRandomString(64, alpha: true, numeric: true),
|
||||
|
@ -75,6 +75,10 @@ namespace Bit.Setup
|
||||
{
|
||||
_context.Install.Domain = _context.Parameters["domain"].ToLowerInvariant();
|
||||
}
|
||||
if (_context.Parameters.ContainsKey("dbname"))
|
||||
{
|
||||
_context.Install.Database = _context.Parameters["dbname"];
|
||||
}
|
||||
|
||||
if (_context.Stub)
|
||||
{
|
||||
@ -201,16 +205,16 @@ namespace Bit.Setup
|
||||
{
|
||||
var installationId = string.Empty;
|
||||
var installationKey = string.Empty;
|
||||
|
||||
|
||||
if (_context.Parameters.ContainsKey("install-id"))
|
||||
{
|
||||
installationId = _context.Parameters["install-id"].ToLowerInvariant();
|
||||
}
|
||||
else
|
||||
{
|
||||
installationId = Helpers.ReadInput("Enter your installation id (get at https://bitwarden.com/host)");
|
||||
installationId = Helpers.ReadInput("Enter your installation id (get at https://bitwarden.com/host)");
|
||||
}
|
||||
|
||||
|
||||
if (!Guid.TryParse(installationId.Trim(), out var installationidGuid))
|
||||
{
|
||||
Console.WriteLine("Invalid installation id.");
|
||||
@ -225,7 +229,7 @@ namespace Bit.Setup
|
||||
{
|
||||
installationKey = Helpers.ReadInput("Enter your installation key");
|
||||
}
|
||||
|
||||
|
||||
_context.Install.InstallationId = installationidGuid;
|
||||
_context.Install.InstallationKey = installationKey;
|
||||
|
||||
|
Reference in New Issue
Block a user