Skip to content

Commit

Permalink
Don't show encrypted values in output
Browse files Browse the repository at this point in the history
  • Loading branch information
nmklotas committed Nov 5, 2017
1 parent 5fb558d commit 220fdea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/GitlabCLI.Console/Configuration/AppSettingsStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ public AppSettingsStorage(JsonSerializer serializer, string settingsFile, Encryp
_encryptor = encryptor;
}

public AppSettings LoadWithSensitiveDataEncrypted()
=> LoadSettingsFromFile();

public AppSettings Load()
{
var settings = LoadSettingsFromFile();
DecryptSensitiveData(settings);
return settings;
}

private AppSettings LoadSettingsFromFile()
{
EnsureSettingsDirectoryExists();

Expand All @@ -29,9 +39,7 @@ public AppSettings Load()
using (var settingsStream = File.OpenText(_settingsFile))
using (var textReader = new JsonTextReader(settingsStream))
{
var settings = _serializer.Deserialize<AppSettings>(textReader) ?? new AppSettings();
DecryptSensitiveData(settings);
return settings;
return _serializer.Deserialize<AppSettings>(textReader) ?? new AppSettings();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/GitlabCLI.Console/Configuration/ConfigurationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public void StoreConfiguration(ConfigurationParameters parameters)
if (SaveConfigurationValues(parameters, settings))
_outputPresenter.ShowMessage("Configuration saved successfully.");

ShowConfiguration(settings);
var encryptedSettings = _storage.LoadWithSensitiveDataEncrypted();
ShowConfiguration(encryptedSettings);
}

private void ShowConfiguration(AppSettings settings)
Expand Down

0 comments on commit 220fdea

Please sign in to comment.