Skip to content

Commit

Permalink
Merge pull request #551 from Orckestra/dev
Browse files Browse the repository at this point in the history
C1 CMS 6.4
  • Loading branch information
napernik authored Mar 5, 2018
2 parents c5bfe27 + 264704e commit ba75fb5
Show file tree
Hide file tree
Showing 53 changed files with 584 additions and 361 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


/.vs
/Composite/bin
/Composite/obj
Expand Down Expand Up @@ -36,3 +36,5 @@
/Packages/
selenium-debug.log
/Website/test/e2e/reports/

GitCommitInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e)
{
using (ThreadDataManager.Initialize())
using (ServiceLocator.EnsureThreadDataServiceScope())
{
Execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ protected override void Execute()
var publishSchedule = PublishScheduleHelper.GetPublishSchedule(type, DataId, LocaleName);
DataFacade.Delete(publishSchedule);

var data = (IPublishControlled)DataFacade.GetDataByUniqueKey(type, DataId);
Verify.IsNotNull(data, "The data with the id '{0}' does not exist", DataId);
var data = (IPublishControlled)DataFacade.TryGetDataByUniqueKey(type, DataId);
if (data == null)
{
Log.LogWarning(LogTitle, $"Failed to find data of type '{type}' by id '{DataId}'.");

transaction.Complete();
return;
}

dataEntityToken = data.GetDataEntityToken();

Expand All @@ -49,11 +55,11 @@ protected override void Execute()

DataFacade.Update(data);

Log.LogVerbose(LogTitle, "Scheduled publishing of data with label '{0}' is complete", data.GetLabel());
Log.LogVerbose(LogTitle, $"Scheduled publishing of data with label '{data.GetLabel()}' is complete");
}
else
{
Log.LogWarning(LogTitle, "Scheduled publishing of data with label '{0}' could not be done because the data is not in a publisheble state", data.GetLabel());
Log.LogWarning(LogTitle, $"Scheduled publishing of data with label '{data.GetLabel()}' could not be done because the data is not in a publisheble state");
}

transaction.Complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ protected override void Execute()

DataFacade.Delete(unpublishSchedule);

var deletePublished = false;
var data = (IPublishControlled)DataFacade.TryGetDataByUniqueKey(type, DataId);
if (data == null)
{
Log.LogWarning(LogTitle, $"Failed to find data of type '{type}' by id '{DataId}'.");

var data = (IPublishControlled)DataFacade.GetDataByUniqueKey(type, DataId);
Verify.IsNotNull(data, "The data with the id {0} does not exist", DataId);
transaction.Complete();
return;
}

var deletePublished = false;

dataEntityToken = data.GetDataEntityToken();

Expand All @@ -56,7 +62,7 @@ protected override void Execute()
}
else
{
Log.LogWarning(LogTitle, "Scheduled unpublishing of data with label '{0}' could not be done because the data is not in a unpublisheble state", data.GetLabel());
Log.LogWarning(LogTitle, $"Scheduled unpublishing of data with label '{data.GetLabel()}' could not be done because the data is not in a unpublisheble state");
}


Expand All @@ -69,7 +75,7 @@ protected override void Execute()
{
DataFacade.Delete(deletedData, CascadeDeleteType.Disable);

Log.LogVerbose(LogTitle, "Scheduled unpublishing of data with label '{0}' is complete", deletedData.GetLabel());
Log.LogVerbose(LogTitle, $"Scheduled unpublishing of data with label '{deletedData.GetLabel()}' is complete");
}
}
}
Expand Down
22 changes: 19 additions & 3 deletions Composite.Workflows/Composite.Workflows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RootNamespace>Composite</RootNamespace>
<AssemblyName>Composite.Workflows</AssemblyName>
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
Expand Down Expand Up @@ -965,6 +965,7 @@
<Compile Include="C1Console\Users\Workflows\ChangeOwnPasswordWorkflow.designer.cs">
<DependentUpon>ChangeOwnPasswordWorkflow.cs</DependentUpon>
</Compile>
<Compile Include="Properties\GitCommitInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="C1Console\Actions\Workflows\EntityTokenLockedWorkflow.layout">
Expand Down Expand Up @@ -1362,11 +1363,26 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Target Name="BeforeBuild">
<PropertyGroup>
<GitBranchFile>$(ProjectDir)git_branch.txt</GitBranchFile>
<GitCommitHashFile>$(ProjectDir)git_commithash.txt</GitCommitHashFile>
</PropertyGroup>
<Exec Command="git -C $(ProjectDir) rev-parse --abbrev-ref HEAD&gt; &quot;$(GitBranchFile)&quot;" />
<Exec Command="git -C $(ProjectDir) rev-parse HEAD&gt; &quot;$(GitCommitHashFile)&quot;" />
<PropertyGroup>
<GitBranch>$([System.IO.File]::ReadAllText("$(GitBranchFile)").Trim())</GitBranch>
<GitCommitHash>$([System.IO.File]::ReadAllText("$(GitCommitHashFile)").Trim())</GitCommitHash>
<AssemblyInformationalVersionAttribute>[assembly: System.Reflection.AssemblyInformationalVersion("$(GitBranch). Commit Hash: $(GitCommitHash)")]</AssemblyInformationalVersionAttribute>
</PropertyGroup>
<WriteLinesToFile File="Properties\GitCommitInfo.cs" Lines="$(AssemblyInformationalVersionAttribute)" Overwrite="true">
</WriteLinesToFile>
<Exec Command="del &quot;$(GitBranchFile)&quot;" />
<Exec Command="del &quot;$(GitCommitHashFile)&quot;" />
</Target>
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "$(ProjectDir)..\bin\"
copy "$(TargetPath)" "$(ProjectDir)..\Website\bin\"</PostBuildEvent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ static LoginSessionStorePluginFacade()

public static bool HasConfiguration()
{
return (ConfigurationServices.ConfigurationSource != null) &&
(ConfigurationServices.ConfigurationSource.GetSection(LoginSessionStoreSettings.SectionName) != null);
return ConfigurationServices.ConfigurationSource?.GetSection(LoginSessionStoreSettings.SectionName) != null;
}


Expand All @@ -53,26 +52,23 @@ public static void StoreUsername(string userName, bool persistAcrossSessions)
}


public static void FlushUsername()
public static string Logout()
{
using (_resourceLocker.ReadLocker)
{
_resourceLocker.Resources.Provider.FlushUsername();
}
}
var provider = _resourceLocker.Resources.Provider;

provider.FlushUsername();


public static string StoredUsername
{
get
{
return _resourceLocker.Resources.Provider.StoredUsername;
return (provider as ILoginSessionStoreRedirectedLogout)?.LogoutUrl;
}
}



public static string StoredUsername => _resourceLocker.Resources.Provider.StoredUsername;


public static IPAddress UserIpAddress
{
get
Expand All @@ -97,15 +93,15 @@ private static void HandleConfigurationError(Exception ex)
{
Flush();

throw new ConfigurationErrorsException(string.Format("Failed to load the configuration section '{0}' from the configuration.", LoginSessionStoreSettings.SectionName), ex);
throw new ConfigurationErrorsException($"Failed to load the configuration section '{LoginSessionStoreSettings.SectionName}' from the configuration.", ex);
}



private sealed class Resources
{
public LoginSessionStoreFactory Factory { get; set; }
public ILoginSessionStore Provider { get; set; }
private LoginSessionStoreFactory Factory { get; set; }
public ILoginSessionStore Provider { get; private set; }

public static void DoInitializeResources(Resources resources)
{
Expand All @@ -127,7 +123,7 @@ public static void DoInitializeResources(Resources resources)
}
else if (RuntimeInformation.IsUnittest)
{
// This is a fall bakc for unittests
// This is a fallback for unittests
resources.Provider = new BuildinLoginSessionStore();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Composite.C1Console.Security.Plugins.LoginSessionStore
{
/// <summary>
/// Allows specifying a logout URL.
/// </summary>
public interface ILoginSessionStoreRedirectedLogout
{
/// <exclude />
string LogoutUrl { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Castle.Core.Internal;

namespace Composite.C1Console.Security.Plugins.LoginSessionStore.Runtime
{
internal class LoginSessionStoreResolver : ILoginSessionStore
internal class LoginSessionStoreResolver : ILoginSessionStore, ILoginSessionStoreRedirectedLogout
{
private readonly IEnumerable<ILoginSessionStore> _loginSessionStores;

Expand Down Expand Up @@ -36,5 +36,10 @@ public void FlushUsername()
}

public IPAddress UserIpAddress => PreferredLoginSessionStore()?.UserIpAddress;

public string LogoutUrl => _loginSessionStores
.OfType<ILoginSessionStoreRedirectedLogout>()
.Select(_ => _.LogoutUrl)
.FirstOrDefault(url => !string.IsNullOrEmpty(url));
}
}
44 changes: 16 additions & 28 deletions Composite/C1Console/Security/UserValidationFacade.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Web;
using Composite.Core.Extensions;
using Composite.Core.Logging;
using Composite.C1Console.Security.Foundation.PluginFacades;
using Composite.C1Console.Security.Plugins.LoginProvider;
Expand Down Expand Up @@ -54,29 +53,17 @@ public static ValidationType GetValidationType()
return ValidationType.Windows;
}

throw new InvalidOperationException(string.Format("Validation plugin '{0}' does not implement a known validation interface", LoginProviderPluginFacade.GetValidationPluginType()));
throw new InvalidOperationException($"Validation plugin '{LoginProviderPluginFacade.GetValidationPluginType()}' does not implement a known validation interface");
}



/// <exclude />
public static IEnumerable<string> AllUsernames
{
get
{
return LoginProviderPluginFacade.AllUsernames;
}
}
public static IEnumerable<string> AllUsernames => LoginProviderPluginFacade.AllUsernames;


/// <exclude />
public static bool CanSetUserPassword
{
get
{
return LoginProviderPluginFacade.CanSetUserPassword;
}
}
public static bool CanSetUserPassword => LoginProviderPluginFacade.CanSetUserPassword;


/// <summary>
Expand Down Expand Up @@ -106,7 +93,7 @@ public static LoginResult FormValidateUser(string userName, string password)

if (loginResult == LoginResult.Success)
{
LoggingService.LogVerbose("UserValidation", String.Format("The user: [{0}], has been validated and accepted. {1}", userName, GetIpInformation()), LoggingService.Category.Audit);
LoggingService.LogVerbose("UserValidation", $"The user: [{userName}], has been validated and accepted. {GetIpInformation()}", LoggingService.Category.Audit);
PersistUsernameInSessionDataProvider(userName);
}
else if (LoginResultDescriptions.ContainsKey(loginResult))
Expand All @@ -120,7 +107,7 @@ public static LoginResult FormValidateUser(string userName, string password)
private static void LogLoginFailed(string userName, string message)
{
LoggingService.LogWarning("UserValidation",
"Login as [{0}] failed. {1} {2}".FormatWith(userName, message, GetIpInformation()),
$"Login as [{userName}] failed. {message} {GetIpInformation()}",
LoggingService.Category.Audit);
}

Expand All @@ -145,7 +132,7 @@ private static string GetIpInformation()
return string.Empty;
}

return " IP address: " + ipaddress;
return "IP address: " + ipaddress;
}


Expand Down Expand Up @@ -185,20 +172,21 @@ public static bool WindowsValidateUser(string userName, string domainName)


/// <summary>
/// Flushes the username from the login session
/// Flushes the username from the login session.
/// </summary>
public static void Logout()
{
LoginSessionStorePluginFacade.FlushUsername();
}
[Obsolete("Use Logout() instead.")]
public static void FlushUsername() => Logout();



/// <summary>
/// Flushes the username from the login session (if applicable) and returns a logout URL.
/// </summary>
public static string Logout() => LoginSessionStorePluginFacade.Logout();


/// <exclude />
public static bool IsLoggedIn()
{
return !string.IsNullOrEmpty(LoginSessionStorePluginFacade.StoredUsername);
}
public static bool IsLoggedIn() => !string.IsNullOrEmpty(LoginSessionStorePluginFacade.StoredUsername);



Expand Down
Loading

0 comments on commit ba75fb5

Please sign in to comment.