mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-12-23 08:56:02 +01:00
Merge pull request #1055 from Frezzle/CP-17933
CP-17933: Add feature flag for proxy authentication
This commit is contained in:
commit
16ebd4c496
@ -80,6 +80,14 @@ namespace XenAdmin.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static bool ProxyAuthenticationEnabled
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ReadBool(PROXY_AUTHENTICATION_ENABLED, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static SSLCertificateTypes AlwaysShowSSLCertificates
|
public static SSLCertificateTypes AlwaysShowSSLCertificates
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -402,6 +410,7 @@ namespace XenAdmin.Core
|
|||||||
private const string HEALTH_CHECK_PRODUCT_KEY = "HealthCheckProductKey";
|
private const string HEALTH_CHECK_PRODUCT_KEY = "HealthCheckProductKey";
|
||||||
private const string HIDDEN_FEATURES = "HiddenFeatures";
|
private const string HIDDEN_FEATURES = "HiddenFeatures";
|
||||||
private const string ADDITIONAL_FEATURES = "AdditionalFeatures";
|
private const string ADDITIONAL_FEATURES = "AdditionalFeatures";
|
||||||
|
private const string PROXY_AUTHENTICATION_ENABLED = "ProxyAuthenticationEnabled";
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SSLCertificateTypes { None, Changed, All }
|
public enum SSLCertificateTypes { None, Changed, All }
|
||||||
|
@ -51,8 +51,8 @@ namespace XenAdmin.Dialogs.OptionsPages
|
|||||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private OptionsDialog optionsDialog;
|
private OptionsDialog optionsDialog;
|
||||||
|
|
||||||
// used for preventing the event handlers (mainly the SelectUseThisProxyServer function) from being called when loading the settings into the text/check boxes
|
// used for preventing the event handlers from doing anything when changing controls through code
|
||||||
private bool built = false;
|
private bool eventsDisabled = true;
|
||||||
|
|
||||||
public ConnectionOptionsPage()
|
public ConnectionOptionsPage()
|
||||||
{
|
{
|
||||||
@ -88,6 +88,9 @@ namespace XenAdmin.Dialogs.OptionsPages
|
|||||||
ProxyAddressTextBox.Text = Properties.Settings.Default.ProxyAddress;
|
ProxyAddressTextBox.Text = Properties.Settings.Default.ProxyAddress;
|
||||||
ProxyPortTextBox.Text = Properties.Settings.Default.ProxyPort.ToString();
|
ProxyPortTextBox.Text = Properties.Settings.Default.ProxyPort.ToString();
|
||||||
BypassForServersCheckbox.Checked = Properties.Settings.Default.BypassProxyForServers;
|
BypassForServersCheckbox.Checked = Properties.Settings.Default.BypassProxyForServers;
|
||||||
|
|
||||||
|
if (Registry.ProxyAuthenticationEnabled)
|
||||||
|
{
|
||||||
AuthenticationCheckBox.Checked = Properties.Settings.Default.ProvideProxyAuthentication;
|
AuthenticationCheckBox.Checked = Properties.Settings.Default.ProvideProxyAuthentication;
|
||||||
|
|
||||||
// checks for empty default username/password which starts out unencrypted
|
// checks for empty default username/password which starts out unencrypted
|
||||||
@ -95,68 +98,107 @@ namespace XenAdmin.Dialogs.OptionsPages
|
|||||||
ProxyUsernameTextBox.Text = string.IsNullOrEmpty(protectedUsername) ? "" : EncryptionUtils.Unprotect(Properties.Settings.Default.ProxyUsername);
|
ProxyUsernameTextBox.Text = string.IsNullOrEmpty(protectedUsername) ? "" : EncryptionUtils.Unprotect(Properties.Settings.Default.ProxyUsername);
|
||||||
string protectedPassword = Properties.Settings.Default.ProxyPassword;
|
string protectedPassword = Properties.Settings.Default.ProxyPassword;
|
||||||
ProxyPasswordTextBox.Text = string.IsNullOrEmpty(protectedPassword) ? "" : EncryptionUtils.Unprotect(Properties.Settings.Default.ProxyPassword);
|
ProxyPasswordTextBox.Text = string.IsNullOrEmpty(protectedPassword) ? "" : EncryptionUtils.Unprotect(Properties.Settings.Default.ProxyPassword);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// hide controls
|
||||||
|
AuthenticationCheckBox.Visible = false;
|
||||||
|
ProxyUsernameLabel.Visible = false;
|
||||||
|
ProxyUsernameTextBox.Visible = false;
|
||||||
|
ProxyPasswordLabel.Visible = false;
|
||||||
|
ProxyPasswordTextBox.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
ConnectionTimeoutNud.Value = Properties.Settings.Default.ConnectionTimeout / 1000;
|
ConnectionTimeoutNud.Value = Properties.Settings.Default.ConnectionTimeout / 1000;
|
||||||
|
|
||||||
built = true;
|
eventsDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UseProxyRadioButton_CheckedChanged(object sender, EventArgs e)
|
private void UseProxyRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (eventsDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
enableOK();
|
enableOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AuthenticationCheckBox_CheckedChanged(object sender, EventArgs e)
|
private void AuthenticationCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (eventsDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eventsDisabled = true;
|
||||||
|
|
||||||
if (!AuthenticationCheckBox.Checked)
|
if (!AuthenticationCheckBox.Checked)
|
||||||
{
|
{
|
||||||
ProxyUsernameTextBox.Clear();
|
ProxyUsernameTextBox.Clear();
|
||||||
ProxyPasswordTextBox.Clear();
|
ProxyPasswordTextBox.Clear();
|
||||||
AuthenticationCheckBox.Checked = false; // have to redo this as the 2 Clears above cause the checkbox to recheck
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectUseThisProxyServer();
|
SelectUseThisProxyServer();
|
||||||
|
|
||||||
|
eventsDisabled = false;
|
||||||
|
|
||||||
enableOK();
|
enableOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProxyAddressTextBox_TextChanged(object sender, EventArgs e)
|
private void ProxyAddressTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (eventsDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
SelectUseThisProxyServer();
|
SelectUseThisProxyServer();
|
||||||
|
|
||||||
enableOK();
|
enableOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProxyPortTextBox_TextChanged(object sender, EventArgs e)
|
private void ProxyPortTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (eventsDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
SelectUseThisProxyServer();
|
SelectUseThisProxyServer();
|
||||||
|
|
||||||
enableOK();
|
enableOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProxyUsernameTextBox_TextChanged(object sender, EventArgs e)
|
private void ProxyUsernameTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SelectUseThisProxyServer();
|
if (eventsDisabled)
|
||||||
if (!AuthenticationCheckBox.Checked)
|
return;
|
||||||
AuthenticationCheckBox.Checked = true;
|
|
||||||
|
SelectProvideCredentials();
|
||||||
|
|
||||||
enableOK();
|
enableOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProxyPasswordTextBox_TextChanged(object sender, EventArgs e)
|
private void ProxyPasswordTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SelectUseThisProxyServer();
|
if (eventsDisabled)
|
||||||
if (!AuthenticationCheckBox.Checked)
|
return;
|
||||||
AuthenticationCheckBox.Checked = true;
|
|
||||||
|
SelectProvideCredentials();
|
||||||
|
|
||||||
enableOK();
|
enableOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BypassForServersCheckbox_CheckedChanged(object sender, EventArgs e)
|
private void BypassForServersCheckbox_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (eventsDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
SelectUseThisProxyServer();
|
SelectUseThisProxyServer();
|
||||||
|
|
||||||
enableOK();
|
enableOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectUseThisProxyServer()
|
private void SelectUseThisProxyServer()
|
||||||
{
|
{
|
||||||
if (!UseProxyRadioButton.Checked && built)
|
UseProxyRadioButton.Checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectProvideCredentials()
|
||||||
|
{
|
||||||
|
AuthenticationCheckBox.Checked = true;
|
||||||
UseProxyRadioButton.Checked = true;
|
UseProxyRadioButton.Checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,8 +265,12 @@ namespace XenAdmin.Dialogs.OptionsPages
|
|||||||
if (ProxyAddressTextBox.Text != Properties.Settings.Default.ProxyAddress && !string.IsNullOrEmpty(ProxyAddressTextBox.Text))
|
if (ProxyAddressTextBox.Text != Properties.Settings.Default.ProxyAddress && !string.IsNullOrEmpty(ProxyAddressTextBox.Text))
|
||||||
Properties.Settings.Default.ProxyAddress = ProxyAddressTextBox.Text;
|
Properties.Settings.Default.ProxyAddress = ProxyAddressTextBox.Text;
|
||||||
|
|
||||||
|
if (Registry.ProxyAuthenticationEnabled)
|
||||||
|
{
|
||||||
Properties.Settings.Default.ProxyUsername = EncryptionUtils.Protect(ProxyUsernameTextBox.Text);
|
Properties.Settings.Default.ProxyUsername = EncryptionUtils.Protect(ProxyUsernameTextBox.Text);
|
||||||
Properties.Settings.Default.ProxyPassword = EncryptionUtils.Protect(ProxyPasswordTextBox.Text);
|
Properties.Settings.Default.ProxyPassword = EncryptionUtils.Protect(ProxyPasswordTextBox.Text);
|
||||||
|
Properties.Settings.Default.ProvideProxyAuthentication = AuthenticationCheckBox.Checked;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -240,9 +286,6 @@ namespace XenAdmin.Dialogs.OptionsPages
|
|||||||
if (BypassForServersCheckbox.Checked != Properties.Settings.Default.BypassProxyForServers)
|
if (BypassForServersCheckbox.Checked != Properties.Settings.Default.BypassProxyForServers)
|
||||||
Properties.Settings.Default.BypassProxyForServers = BypassForServersCheckbox.Checked;
|
Properties.Settings.Default.BypassProxyForServers = BypassForServersCheckbox.Checked;
|
||||||
|
|
||||||
if (AuthenticationCheckBox.Checked != Properties.Settings.Default.ProvideProxyAuthentication)
|
|
||||||
Properties.Settings.Default.ProvideProxyAuthentication = AuthenticationCheckBox.Checked;
|
|
||||||
|
|
||||||
// timeout settings
|
// timeout settings
|
||||||
int timeout = (int)ConnectionTimeoutNud.Value;
|
int timeout = (int)ConnectionTimeoutNud.Value;
|
||||||
if (timeout * 1000 != Properties.Settings.Default.ConnectionTimeout)
|
if (timeout * 1000 != Properties.Settings.Default.ConnectionTimeout)
|
||||||
|
@ -985,6 +985,11 @@ namespace XenAdmin
|
|||||||
|
|
||||||
public static void ReconfigureConnectionSettings()
|
public static void ReconfigureConnectionSettings()
|
||||||
{
|
{
|
||||||
|
if (!Registry.ProxyAuthenticationEnabled)
|
||||||
|
{
|
||||||
|
Properties.Settings.Default.ProvideProxyAuthentication = false;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
}
|
||||||
XenAPI.Session.Proxy = XenAdminConfigManager.Provider.GetProxyFromSettings(null);
|
XenAPI.Session.Proxy = XenAdminConfigManager.Provider.GetProxyFromSettings(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user