fix(client-ui): resolve Medium code-review finding (Client.UI-007)
Remove Password from UserSettings and stop writing it to settings.json; the operator is re-prompted on each launch. Update LoadSettings/SaveSettings comments and adjust the affected test assertion to verify the password is not restored from the persisted model. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,11 +17,6 @@ public sealed class UserSettings
|
||||
/// </summary>
|
||||
public string? Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the persisted password for authenticated sessions.
|
||||
/// </summary>
|
||||
public string? Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the transport security mode selected by the user.
|
||||
/// </summary>
|
||||
|
||||
@@ -380,7 +380,7 @@ public partial class MainWindowViewModel : ObservableObject
|
||||
var s = _settingsService.Load();
|
||||
EndpointUrl = s.EndpointUrl;
|
||||
Username = s.Username;
|
||||
Password = s.Password;
|
||||
// Password is intentionally not persisted (security: re-prompt each launch)
|
||||
SelectedSecurityMode = s.SecurityMode;
|
||||
FailoverUrls = s.FailoverUrls;
|
||||
SessionTimeoutSeconds = s.SessionTimeoutSeconds;
|
||||
@@ -400,7 +400,7 @@ public partial class MainWindowViewModel : ObservableObject
|
||||
{
|
||||
EndpointUrl = EndpointUrl,
|
||||
Username = Username,
|
||||
Password = Password,
|
||||
// Password is intentionally not persisted (security: re-prompt each launch)
|
||||
SecurityMode = SelectedSecurityMode,
|
||||
FailoverUrls = FailoverUrls,
|
||||
SessionTimeoutSeconds = SessionTimeoutSeconds,
|
||||
|
||||
@@ -438,7 +438,6 @@ public class MainWindowViewModelTests
|
||||
{
|
||||
EndpointUrl = "opc.tcp://saved:5555",
|
||||
Username = "savedUser",
|
||||
Password = "savedPass",
|
||||
SecurityMode = SecurityMode.Sign,
|
||||
FailoverUrls = "opc.tcp://backup:5555",
|
||||
SessionTimeoutSeconds = 120,
|
||||
@@ -458,7 +457,8 @@ public class MainWindowViewModelTests
|
||||
|
||||
vm.EndpointUrl.ShouldBe("opc.tcp://saved:5555");
|
||||
vm.Username.ShouldBe("savedUser");
|
||||
vm.Password.ShouldBe("savedPass");
|
||||
// Password is intentionally not persisted: re-prompt each launch
|
||||
vm.Password.ShouldBeNull();
|
||||
vm.SelectedSecurityMode.ShouldBe(SecurityMode.Sign);
|
||||
vm.FailoverUrls.ShouldBe("opc.tcp://backup:5555");
|
||||
vm.SessionTimeoutSeconds.ShouldBe(120);
|
||||
|
||||
Reference in New Issue
Block a user