SEBWIN-363, SEBWIN-357: Ensured session is retained when loading a configuration from a server which requires authentication and introduced new flag to determine whether a reconfiguration is allowed or not. Also fixed session persistence when using delete cookies settings.
This commit is contained in:
parent
1d9f5ffad7
commit
07bb78e637
11 changed files with 52 additions and 19 deletions
|
@ -213,7 +213,7 @@ namespace SafeExamBrowser.Browser
|
||||||
cefSettings.CefCommandLineArgs.Add("touch-events", "enabled");
|
cefSettings.CefCommandLineArgs.Add("touch-events", "enabled");
|
||||||
cefSettings.LogFile = appConfig.BrowserLogFilePath;
|
cefSettings.LogFile = appConfig.BrowserLogFilePath;
|
||||||
cefSettings.LogSeverity = error ? LogSeverity.Error : (warning ? LogSeverity.Warning : LogSeverity.Info);
|
cefSettings.LogSeverity = error ? LogSeverity.Error : (warning ? LogSeverity.Warning : LogSeverity.Info);
|
||||||
cefSettings.PersistSessionCookies = !settings.DeleteCookiesOnShutdown;
|
cefSettings.PersistSessionCookies = !settings.DeleteCookiesOnStartup || !settings.DeleteCookiesOnShutdown;
|
||||||
cefSettings.UserAgent = InitializeUserAgent();
|
cefSettings.UserAgent = InitializeUserAgent();
|
||||||
|
|
||||||
if (!settings.AllowPdfReader)
|
if (!settings.AllowPdfReader)
|
||||||
|
|
|
@ -626,7 +626,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
var args = new DownloadEventArgs();
|
var args = new DownloadEventArgs();
|
||||||
|
|
||||||
appConfig.TemporaryDirectory = @"C:\Folder\Does\Not\Exist";
|
appConfig.TemporaryDirectory = @"C:\Folder\Does\Not\Exist";
|
||||||
settings.ConfigurationMode = ConfigurationMode.ConfigureClient;
|
settings.Security.AllowReconfiguration = true;
|
||||||
messageBox.Setup(m => m.Show(
|
messageBox.Setup(m => m.Show(
|
||||||
It.IsAny<TextKey>(),
|
It.IsAny<TextKey>(),
|
||||||
It.IsAny<TextKey>(),
|
It.IsAny<TextKey>(),
|
||||||
|
@ -653,7 +653,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
var args = new DownloadEventArgs();
|
var args = new DownloadEventArgs();
|
||||||
|
|
||||||
appConfig.TemporaryDirectory = @"C:\Folder\Does\Not\Exist";
|
appConfig.TemporaryDirectory = @"C:\Folder\Does\Not\Exist";
|
||||||
settings.ConfigurationMode = ConfigurationMode.ConfigureClient;
|
settings.Security.AllowReconfiguration = true;
|
||||||
messageBox.Setup(m => m.Show(
|
messageBox.Setup(m => m.Show(
|
||||||
It.IsAny<TextKey>(),
|
It.IsAny<TextKey>(),
|
||||||
It.IsAny<TextKey>(),
|
It.IsAny<TextKey>(),
|
||||||
|
@ -677,7 +677,7 @@ namespace SafeExamBrowser.Client.UnitTests
|
||||||
var args = new DownloadEventArgs();
|
var args = new DownloadEventArgs();
|
||||||
|
|
||||||
appConfig.TemporaryDirectory = @"C:\Folder\Does\Not\Exist";
|
appConfig.TemporaryDirectory = @"C:\Folder\Does\Not\Exist";
|
||||||
settings.ConfigurationMode = ConfigurationMode.ConfigureClient;
|
settings.Security.AllowReconfiguration = true;
|
||||||
messageBox.Setup(m => m.Show(
|
messageBox.Setup(m => m.Show(
|
||||||
It.IsAny<TextKey>(),
|
It.IsAny<TextKey>(),
|
||||||
It.IsAny<TextKey>(),
|
It.IsAny<TextKey>(),
|
||||||
|
|
|
@ -337,7 +337,7 @@ namespace SafeExamBrowser.Client
|
||||||
|
|
||||||
private void Browser_ConfigurationDownloadRequested(string fileName, DownloadEventArgs args)
|
private void Browser_ConfigurationDownloadRequested(string fileName, DownloadEventArgs args)
|
||||||
{
|
{
|
||||||
if (Settings.ConfigurationMode == ConfigurationMode.ConfigureClient)
|
if (Settings.Security.AllowReconfiguration)
|
||||||
{
|
{
|
||||||
args.AllowDownload = true;
|
args.AllowDownload = true;
|
||||||
args.Callback = Browser_ConfigurationDownloadFinished;
|
args.Callback = Browser_ConfigurationDownloadFinished;
|
||||||
|
@ -353,7 +353,7 @@ namespace SafeExamBrowser.Client
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
args.AllowDownload = false;
|
args.AllowDownload = false;
|
||||||
logger.Info($"Denied download request for configuration file '{fileName}' due to '{Settings.ConfigurationMode}' mode.");
|
logger.Info($"Denied download request for configuration file '{fileName}'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,22 @@ namespace SafeExamBrowser.Configuration.UnitTests.ConfigurationData
|
||||||
sut = new DataProcessor();
|
sut = new DataProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void MustAllowReconfigurationAccordingToMode()
|
||||||
|
{
|
||||||
|
var settings1 = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||||
|
var settings2 = new AppSettings { ConfigurationMode = ConfigurationMode.Exam };
|
||||||
|
|
||||||
|
settings1.Security.AllowReconfiguration = false;
|
||||||
|
settings2.Security.AllowReconfiguration = true;
|
||||||
|
|
||||||
|
sut.Process(new Dictionary<string, object>(), settings1);
|
||||||
|
sut.Process(new Dictionary<string, object>(), settings2);
|
||||||
|
|
||||||
|
Assert.IsTrue(settings1.Security.AllowReconfiguration);
|
||||||
|
Assert.IsFalse(settings2.Security.AllowReconfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void MustCalculateCorrectConfigurationKey()
|
public void MustCalculateCorrectConfigurationKey()
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,9 +20,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
{
|
{
|
||||||
internal void Process(IDictionary<string, object> rawData, AppSettings settings)
|
internal void Process(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
{
|
{
|
||||||
|
AllowReconfiguration(settings);
|
||||||
CalculateConfigurationKey(rawData, settings);
|
CalculateConfigurationKey(rawData, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AllowReconfiguration(AppSettings settings)
|
||||||
|
{
|
||||||
|
settings.Security.AllowReconfiguration = settings.ConfigurationMode == ConfigurationMode.ConfigureClient;
|
||||||
|
}
|
||||||
|
|
||||||
private void CalculateConfigurationKey(IDictionary<string, object> rawData, AppSettings settings)
|
private void CalculateConfigurationKey(IDictionary<string, object> rawData, AppSettings settings)
|
||||||
{
|
{
|
||||||
using (var algorithm = new SHA256Managed())
|
using (var algorithm = new SHA256Managed())
|
||||||
|
|
|
@ -165,6 +165,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.Mouse.AllowRightButton = true;
|
settings.Mouse.AllowRightButton = true;
|
||||||
|
|
||||||
settings.Security.AllowApplicationLogAccess = false;
|
settings.Security.AllowApplicationLogAccess = false;
|
||||||
|
settings.Security.AllowReconfiguration = false;
|
||||||
settings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
settings.Security.KioskMode = KioskMode.CreateNewDesktop;
|
||||||
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny;
|
settings.Security.VirtualMachinePolicy = VirtualMachinePolicy.Deny;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustTestdatalyHandleBrowserResource()
|
public void Perform_MustCorrectlyHandleBrowserResource()
|
||||||
{
|
{
|
||||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.Exam };
|
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.Exam };
|
||||||
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
var url = @"http://www.safeexambrowser.org/whatever.seb";
|
||||||
|
@ -121,6 +121,9 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
var sut = new ConfigurationOperation(new[] { "blubb.exe", url }, repository.Object, fileSystem.Object, hashAlgorithm.Object, logger.Object, sessionContext);
|
||||||
var result = sut.Perform();
|
var result = sut.Perform();
|
||||||
|
|
||||||
|
Assert.IsFalse(settings.Browser.DeleteCacheOnShutdown);
|
||||||
|
Assert.IsFalse(settings.Browser.DeleteCookiesOnShutdown);
|
||||||
|
Assert.IsTrue(settings.Security.AllowReconfiguration);
|
||||||
Assert.AreEqual(url, settings.Browser.StartUrl);
|
Assert.AreEqual(url, settings.Browser.StartUrl);
|
||||||
Assert.AreEqual(OperationResult.Success, result);
|
Assert.AreEqual(OperationResult.Success, result);
|
||||||
}
|
}
|
||||||
|
@ -331,7 +334,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustSucceedIfAdminPasswordTestdata()
|
public void Perform_MustSucceedIfAdminPasswordCorrect()
|
||||||
{
|
{
|
||||||
var password = "test";
|
var password = "test";
|
||||||
var currentSettings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
var currentSettings = new AppSettings { ConfigurationMode = ConfigurationMode.ConfigureClient };
|
||||||
|
@ -394,7 +397,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Perform_MustSucceedIfSettingsPasswordTestdata()
|
public void Perform_MustSucceedIfSettingsPasswordCorrect()
|
||||||
{
|
{
|
||||||
var password = "test";
|
var password = "test";
|
||||||
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.Exam };
|
var settings = new AppSettings { ConfigurationMode = ConfigurationMode.Exam };
|
||||||
|
@ -504,7 +507,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Repeat_MustPerformForExamWithTestdataUri()
|
public void Repeat_MustPerformForExamWithCorrectUri()
|
||||||
{
|
{
|
||||||
var currentSettings = new AppSettings();
|
var currentSettings = new AppSettings();
|
||||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||||
|
@ -526,7 +529,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Repeat_MustPerformForClientConfigurationWithTestdataUri()
|
public void Repeat_MustPerformForClientConfigurationWithCorrectUri()
|
||||||
{
|
{
|
||||||
var currentSettings = new AppSettings();
|
var currentSettings = new AppSettings();
|
||||||
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
var location = Path.GetDirectoryName(GetType().Assembly.Location);
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||||
var args = new ReconfigurationEventArgs { ConfigurationPath = "C:\\Some\\File\\Path.seb" };
|
var args = new ReconfigurationEventArgs { ConfigurationPath = "C:\\Some\\File\\Path.seb" };
|
||||||
|
|
||||||
StartSession();
|
StartSession();
|
||||||
currentSettings.ConfigurationMode = ConfigurationMode.ConfigureClient;
|
currentSettings.Security.AllowReconfiguration = true;
|
||||||
bootstrapSequence.Reset();
|
bootstrapSequence.Reset();
|
||||||
sessionSequence.Reset();
|
sessionSequence.Reset();
|
||||||
sessionSequence.Setup(s => s.TryRepeat()).Returns(OperationResult.Success);
|
sessionSequence.Setup(s => s.TryRepeat()).Returns(OperationResult.Success);
|
||||||
|
@ -182,6 +182,7 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||||
public void Communication_MustInformClientAboutAbortedReconfiguration()
|
public void Communication_MustInformClientAboutAbortedReconfiguration()
|
||||||
{
|
{
|
||||||
StartSession();
|
StartSession();
|
||||||
|
currentSettings.Security.AllowReconfiguration = true;
|
||||||
sessionSequence.Reset();
|
sessionSequence.Reset();
|
||||||
sessionSequence.Setup(s => s.TryRepeat()).Returns(OperationResult.Aborted);
|
sessionSequence.Setup(s => s.TryRepeat()).Returns(OperationResult.Aborted);
|
||||||
|
|
||||||
|
@ -196,7 +197,7 @@ namespace SafeExamBrowser.Runtime.UnitTests
|
||||||
var args = new ReconfigurationEventArgs { ConfigurationPath = "C:\\Some\\File\\Path.seb" };
|
var args = new ReconfigurationEventArgs { ConfigurationPath = "C:\\Some\\File\\Path.seb" };
|
||||||
|
|
||||||
StartSession();
|
StartSession();
|
||||||
currentSettings.ConfigurationMode = ConfigurationMode.Exam;
|
currentSettings.Security.AllowReconfiguration = false;
|
||||||
bootstrapSequence.Reset();
|
bootstrapSequence.Reset();
|
||||||
sessionSequence.Reset();
|
sessionSequence.Reset();
|
||||||
|
|
||||||
|
|
|
@ -204,8 +204,12 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
|
|
||||||
private OperationResult HandleBrowserResource(Uri uri)
|
private OperationResult HandleBrowserResource(Uri uri)
|
||||||
{
|
{
|
||||||
|
Context.Next.Settings.Browser.DeleteCacheOnShutdown = false;
|
||||||
|
Context.Next.Settings.Browser.DeleteCookiesOnShutdown = false;
|
||||||
Context.Next.Settings.Browser.StartUrl = uri.AbsoluteUri;
|
Context.Next.Settings.Browser.StartUrl = uri.AbsoluteUri;
|
||||||
logger.Info($"The configuration resource needs authentication or is a webpage, using '{uri}' as startup URL for the browser.");
|
Context.Next.Settings.Security.AllowReconfiguration = true;
|
||||||
|
|
||||||
|
logger.Info($"The configuration resource needs authentication or is a webpage, using '{uri}' as start URL for the browser.");
|
||||||
|
|
||||||
return OperationResult.Success;
|
return OperationResult.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ using SafeExamBrowser.I18n.Contracts;
|
||||||
using SafeExamBrowser.Logging.Contracts;
|
using SafeExamBrowser.Logging.Contracts;
|
||||||
using SafeExamBrowser.Runtime.Contracts;
|
using SafeExamBrowser.Runtime.Contracts;
|
||||||
using SafeExamBrowser.Runtime.Operations.Events;
|
using SafeExamBrowser.Runtime.Operations.Events;
|
||||||
using SafeExamBrowser.Settings;
|
|
||||||
using SafeExamBrowser.Settings.Security;
|
using SafeExamBrowser.Settings.Security;
|
||||||
using SafeExamBrowser.Settings.Service;
|
using SafeExamBrowser.Settings.Service;
|
||||||
using SafeExamBrowser.UserInterface.Contracts;
|
using SafeExamBrowser.UserInterface.Contracts;
|
||||||
|
@ -344,9 +343,7 @@ namespace SafeExamBrowser.Runtime
|
||||||
|
|
||||||
private void RuntimeHost_ReconfigurationRequested(ReconfigurationEventArgs args)
|
private void RuntimeHost_ReconfigurationRequested(ReconfigurationEventArgs args)
|
||||||
{
|
{
|
||||||
var mode = Session.Settings.ConfigurationMode;
|
if (Session.Settings.Security.AllowReconfiguration)
|
||||||
|
|
||||||
if (mode == ConfigurationMode.ConfigureClient)
|
|
||||||
{
|
{
|
||||||
logger.Info($"Accepted request for reconfiguration with '{args.ConfigurationPath}'.");
|
logger.Info($"Accepted request for reconfiguration with '{args.ConfigurationPath}'.");
|
||||||
sessionContext.ReconfigurationFilePath = args.ConfigurationPath;
|
sessionContext.ReconfigurationFilePath = args.ConfigurationPath;
|
||||||
|
@ -355,7 +352,7 @@ namespace SafeExamBrowser.Runtime
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Info($"Denied request for reconfiguration with '{args.ConfigurationPath}' due to '{mode}' mode!");
|
logger.Info($"Denied request for reconfiguration with '{args.ConfigurationPath}'!");
|
||||||
sessionContext.ClientProxy.InformReconfigurationDenied(args.ConfigurationPath);
|
sessionContext.ClientProxy.InformReconfigurationDenied(args.ConfigurationPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,11 @@ namespace SafeExamBrowser.Settings.Security
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowApplicationLogAccess { get; set; }
|
public bool AllowApplicationLogAccess { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the user may reconfigure the application.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowReconfiguration { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The kiosk mode which determines how the computer is locked down.
|
/// The kiosk mode which determines how the computer is locked down.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue