Skip to content

Commit

Permalink
Refactor parameters to pass a connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
simpat-jesus committed Jul 3, 2024
1 parent 243da9b commit b5f251a
Showing 1 changed file with 6 additions and 37 deletions.
43 changes: 6 additions & 37 deletions Utilities/GenerateSecurityGraphs/GenerateSecurityGraphs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,16 @@ internal class Options
[Option('f', "force", Default = false, HelpText = "Create a folder at that path if one doesn't already exist.")]
public bool Force { get; set; }

[Option('d', "database", Default = "EdFi_Security", HelpText = "The name of the database containing the authorization metadata.")]
public string Database { get; set; }

[Option(
's', "server", Default = "(local)", HelpText = "The name of the SQL Server where the authorization metadata database is located.")]
public string Server { get; set; }

[Option(
'u', "user", HelpText =
"The SQL Server username to use for connecting to the authorization metadata database. Leave username and password blank to use integrated security.")]
public string User { get; set; }

[Option(
'p', "password", HelpText =
"The password to use for connecting to the authorization metadata database. Leave username and password blank to use integrated security.")]
public string Password { get; set; }

[Option(
'g', "graphviz", Default = @"C:\Program Files\Graphviz\", HelpText =
"Graphviz installation path.")]
public string GraphvizPath { get; set; }

[Option(
'c', "connectionString", Required = true,
HelpText = "Provide the connection string for the database, including database name, server name, user and password (if necessary)")]
public string ConnectionString { get; set; }

//[HelpOption]
public string GetUsage(string[] args)
{
Expand Down Expand Up @@ -119,25 +107,6 @@ private static async Task Main(string[] args)

if (failedToParse) return;

string connectionString;

if (options.User == null || options.Password == null)
{
connectionString = string.Format(
"Server={0};Database={1};Trusted_Connection=True",
options.Server,
options.Database);
}
else
{
connectionString = string.Format(
"Server={0};Database={1};User ID={2};Password={3}",
options.Server,
options.Database,
options.User,
options.Password);
}

string baseFolderPath;

if (Path.IsPathRooted(options.OutputFolder))
Expand Down Expand Up @@ -204,7 +173,7 @@ private static async Task Main(string[] args)
var authorizationMetadata = new Dictionary<AuthorizationKey, EffectiveActionAndStrategy>();

List<string> claimSetNames;
var resourceGraph = LoadAuthorizationMetadataGraph(connectionString, out claimSetNames);
var resourceGraph = LoadAuthorizationMetadataGraph(options.ConnectionString, out claimSetNames);

foreach (string claimSetName in claimSetNames)
{
Expand Down

0 comments on commit b5f251a

Please sign in to comment.