webdav portal auth via ad
This commit is contained in:
parent
05d9fddb5d
commit
7dd090820b
56 changed files with 927 additions and 281 deletions
|
@ -1,7 +1,7 @@
|
|||
using System.Configuration;
|
||||
using WebsitePanel.WebDavPortal.WebConfigSections;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public abstract class AbstractConfigCollection
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public class ElementsRendering : AbstractConfigCollection
|
||||
{
|
|
@ -1,9 +1,9 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using WebsitePanel.WebDavPortal.WebConfigSections;
|
||||
using WebsitePanel.WebDav.Core.Config.WebConfigSections;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public class FileIconsDictionary : AbstractConfigCollection, IReadOnlyDictionary<string, string>
|
||||
{
|
|
@ -1,7 +1,6 @@
|
|||
using System.Globalization;
|
||||
using Resources.Resource;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public class HttpErrorsCollection
|
||||
{
|
||||
|
@ -9,14 +8,14 @@ namespace WebsitePanel.WebDavPortal.Config.Entities
|
|||
{
|
||||
get
|
||||
{
|
||||
var message = errors.ResourceManager.GetString("_" + statusCode.ToString(CultureInfo.InvariantCulture));
|
||||
var message = Resources.HttpErrors.ResourceManager.GetString("_" + statusCode.ToString(CultureInfo.InvariantCulture));
|
||||
return message ?? Default;
|
||||
}
|
||||
}
|
||||
|
||||
public string Default
|
||||
{
|
||||
get { return errors.Default; }
|
||||
get { return Resources.HttpErrors.Default; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using WebsitePanel.WebDavPortal.WebConfigSections;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public class OfficeOnlineCollection : AbstractConfigCollection, IReadOnlyCollection<string>
|
||||
{
|
|
@ -1,9 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using WebsitePanel.WebDavPortal.WebConfigSections;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public class SessionKeysCollection : AbstractConfigCollection
|
||||
{
|
||||
|
@ -14,12 +13,12 @@ namespace WebsitePanel.WebDavPortal.Config.Entities
|
|||
_sessionKeys = ConfigSection.SessionKeys.Cast<SessionKeysElement>();
|
||||
}
|
||||
|
||||
public string AccountInfo
|
||||
public string AuthTicket
|
||||
{
|
||||
get
|
||||
{
|
||||
SessionKeysElement sessionKey =
|
||||
_sessionKeys.FirstOrDefault(x => x.Key == SessionKeysElement.AccountInfoKey);
|
||||
_sessionKeys.FirstOrDefault(x => x.Key == SessionKeysElement.AuthTicketKey);
|
||||
return sessionKey != null ? sessionKey.Value : null;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace WebsitePanel.WebDavPortal.Config.Entities
|
||||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public class WebsitePanelConstantUserParameters : AbstractConfigCollection
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using WebsitePanel.WebDavPortal.Config.Entities;
|
||||
using WebsitePanel.WebDav.Core.Config.Entities;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config
|
||||
namespace WebsitePanel.WebDav.Core.Config
|
||||
{
|
||||
public interface IWebDavAppConfig
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
public class ApplicationNameElement : ConfigurationElement
|
||||
{
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
public class AuthTimeoutCookieNameElement : ConfigurationElement
|
||||
{
|
||||
private const string ValueKey = "value";
|
||||
|
||||
[ConfigurationProperty(ValueKey, IsKey = true, IsRequired = true)]
|
||||
public string Value
|
||||
{
|
||||
get { return (string)this[ValueKey]; }
|
||||
set { this[ValueKey] = value; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
public class ElementsRenderingElement : ConfigurationElement
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
public class FileIconsElement : ConfigurationElement
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
[ConfigurationCollection(typeof (FileIconsElement))]
|
||||
public class FileIconsElementCollection : ConfigurationElementCollection
|
|
@ -8,6 +8,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
private const string ValueKey = "value";
|
||||
|
||||
public const string AccountInfoKey = "AccountInfoSessionKey";
|
||||
public const string AuthTicketKey = "AuthTicketKey";
|
||||
public const string WebDavManagerKey = "WebDavManagerSessionKey";
|
||||
public const string ResourseRenderCountKey = "ResourseRenderCountSessionKey";
|
||||
public const string ItemIdSessionKey = "ItemId";
|
|
@ -1,6 +1,7 @@
|
|||
using System.Configuration;
|
||||
using WebsitePanel.WebDavPortal.WebConfigSections;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
[ConfigurationCollection(typeof (SessionKeysElement))]
|
||||
public class SessionKeysElementCollection : ConfigurationElementCollection
|
|
@ -1,6 +1,6 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
public class UserDomainElement : ConfigurationElement
|
||||
{
|
|
@ -1,10 +1,12 @@
|
|||
using System.Configuration;
|
||||
using WebsitePanel.WebDav.Core.Config.WebConfigSections;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
{
|
||||
public class WebDavExplorerConfigurationSettingsSection : ConfigurationSection
|
||||
{
|
||||
private const string UserDomainKey = "userDomain";
|
||||
private const string AuthTimeoutCookieNameKey = "authTimeoutCookieName";
|
||||
private const string AppName = "applicationName";
|
||||
private const string WebsitePanelConstantUserKey = "websitePanelConstantUser";
|
||||
private const string ElementsRenderingKey = "elementsRendering";
|
||||
|
@ -16,6 +18,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
|
||||
public const string SectionName = "webDavExplorerConfigurationSettings";
|
||||
|
||||
[ConfigurationProperty(AuthTimeoutCookieNameKey, IsRequired = true)]
|
||||
public AuthTimeoutCookieNameElement AuthTimeoutCookieName
|
||||
{
|
||||
get { return (AuthTimeoutCookieNameElement)this[AuthTimeoutCookieNameKey]; }
|
||||
set { this[AuthTimeoutCookieNameKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(UserDomainKey, IsRequired = true)]
|
||||
public UserDomainElement UserDomain
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
public class WebsitePanelConstantUserElement : ConfigurationElement
|
||||
{
|
|
@ -1,8 +1,8 @@
|
|||
using System.Configuration;
|
||||
using WebsitePanel.WebDavPortal.Config.Entities;
|
||||
using WebsitePanel.WebDav.Core.Config.Entities;
|
||||
using WebsitePanel.WebDavPortal.WebConfigSections;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Config
|
||||
namespace WebsitePanel.WebDav.Core.Config
|
||||
{
|
||||
public class WebDavAppConfigManager : IWebDavAppConfig
|
||||
{
|
||||
|
@ -35,6 +35,11 @@ namespace WebsitePanel.WebDavPortal.Config
|
|||
get { return _configSection.ApplicationName.Value; }
|
||||
}
|
||||
|
||||
public string AuthTimeoutCookieName
|
||||
{
|
||||
get { return _configSection.AuthTimeoutCookieName.Value; }
|
||||
}
|
||||
|
||||
public ElementsRendering ElementsRendering { get; private set; }
|
||||
public WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; private set; }
|
||||
public SessionKeysCollection SessionKeys { get; private set; }
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Interfaces.Security
|
||||
{
|
||||
public interface IAuthenticationService
|
||||
{
|
||||
WspPrincipal LogIn(string login, string password);
|
||||
void CreateAuthenticationTicket(WspPrincipal principal);
|
||||
void LogOut();
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18449
|
||||
// Runtime Version:4.0.30319.33440
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Resources.Resource {
|
||||
namespace WebsitePanel.WebDav.Core.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
|
@ -18,18 +18,18 @@ namespace Resources.Resource {
|
|||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option or rebuild the Visual Studio project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "12.0.0.0")]
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class errors {
|
||||
internal class HttpErrors {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal errors() {
|
||||
internal HttpErrors() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -39,7 +39,7 @@ namespace Resources.Resource {
|
|||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Resources.Resource.errors", global::System.Reflection.Assembly.Load("App_GlobalResources"));
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WebsitePanel.WebDav.Core.Resources.HttpErrors", typeof(HttpErrors).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
|
@ -60,15 +60,6 @@ namespace Resources.Resource {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Fatal error.
|
||||
/// </summary>
|
||||
internal static string Default {
|
||||
get {
|
||||
return ResourceManager.GetString("Default", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The requested content was not found.
|
||||
/// </summary>
|
||||
|
@ -86,5 +77,14 @@ namespace Resources.Resource {
|
|||
return ResourceManager.GetString("_500", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Fatal error.
|
||||
/// </summary>
|
||||
internal static string Default {
|
||||
get {
|
||||
return ResourceManager.GetString("Default", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.DirectoryServices.AccountManagement;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Security;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||
using WebsitePanel.WebDav.Core.Wsp.Framework;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Security.Authentication
|
||||
{
|
||||
public class FormsAuthenticationService : IAuthenticationService
|
||||
{
|
||||
private readonly ICryptography _cryptography;
|
||||
private readonly PrincipalContext _principalContext;
|
||||
|
||||
public FormsAuthenticationService(ICryptography cryptography)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
_principalContext = new PrincipalContext(ContextType.Domain);
|
||||
}
|
||||
|
||||
public WspPrincipal LogIn(string login, string password)
|
||||
{
|
||||
if (_principalContext.ValidateCredentials(login, password) == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var principal = new WspPrincipal(login);
|
||||
|
||||
var exchangeAccount = WSP.Services.ExchangeServer.GetAccountByAccountNameWithoutItemId(login);
|
||||
var organization = WSP.Services.Organizations.GetOrganization(exchangeAccount.ItemId);
|
||||
|
||||
principal.AccountId = exchangeAccount.AccountId;
|
||||
principal.ItemId = exchangeAccount.ItemId;
|
||||
principal.OrganizationId = organization.OrganizationId;
|
||||
principal.DisplayName = exchangeAccount.DisplayName;
|
||||
principal.EncryptedPassword = _cryptography.Encrypt(password);
|
||||
|
||||
CreateAuthenticationTicket(principal);
|
||||
|
||||
HttpContext.Current.User = principal;
|
||||
|
||||
return principal;
|
||||
}
|
||||
|
||||
public void CreateAuthenticationTicket(WspPrincipal principal)
|
||||
{
|
||||
var serializer = new JavaScriptSerializer();
|
||||
string userData = serializer.Serialize(principal);
|
||||
|
||||
var authTicket = new FormsAuthenticationTicket(1, principal.Identity.Name, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout),
|
||||
FormsAuthentication.SlidingExpiration, userData);
|
||||
|
||||
var encTicket = FormsAuthentication.Encrypt(authTicket);
|
||||
|
||||
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
|
||||
|
||||
if (FormsAuthentication.SlidingExpiration)
|
||||
{
|
||||
cookie.Expires = authTicket.Expiration;
|
||||
}
|
||||
|
||||
HttpContext.Current.Response.Cookies.Add(cookie);
|
||||
}
|
||||
|
||||
public void LogOut()
|
||||
{
|
||||
FormsAuthentication.SignOut();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
using System.Security.Principal;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Security;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Security.Authentication.Principals
|
||||
{
|
||||
public class WspPrincipal : IPrincipal
|
||||
{
|
||||
public int AccountId { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public int ItemId { get; set; }
|
||||
|
||||
public string Login { get; set; }
|
||||
public string EncryptedPassword { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrEmpty(Login) ? Login.Split('@')[0] : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore, ScriptIgnore]
|
||||
public IIdentity Identity { get; private set; }
|
||||
|
||||
public WspPrincipal(string username)
|
||||
{
|
||||
Identity = new GenericIdentity(username);
|
||||
Login = username;
|
||||
}
|
||||
|
||||
public WspPrincipal()
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsInRole(string role)
|
||||
{
|
||||
return Identity.IsAuthenticated
|
||||
&& !string.IsNullOrWhiteSpace(role)
|
||||
&& Roles.IsUserInRole(Identity.Name, role);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Cryptography
|
||||
namespace WebsitePanel.WebDav.Core.Security.Cryptography
|
||||
{
|
||||
public class CryptoUtils : ICryptography
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
namespace WebsitePanel.WebDavPortal.Cryptography
|
||||
namespace WebsitePanel.WebDav.Core.Security.Cryptography
|
||||
{
|
||||
public interface ICryptography
|
||||
{
|
|
@ -11,6 +11,8 @@
|
|||
<AssemblyName>WebsitePanel.WebDav.Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -30,18 +32,82 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\Scheduler Domains\WebsitePanel\Bin\Microsoft.Web.Services3.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.DirectoryServices.AccountManagement" />
|
||||
<Reference Include="System.Web">
|
||||
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WebsitePanel.EnterpriseServer.Client">
|
||||
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WebsitePanel.Providers.Base">
|
||||
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.Providers.Base.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Config\Entities\AbstractConfigCollection.cs" />
|
||||
<Compile Include="Config\Entities\ElementsRendering.cs" />
|
||||
<Compile Include="Config\Entities\FileIconsDictionary.cs" />
|
||||
<Compile Include="Config\Entities\HttpErrorsCollection.cs" />
|
||||
<Compile Include="Config\Entities\OfficeOnlineCollection.cs" />
|
||||
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
|
||||
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
|
||||
<Compile Include="Config\IWebDavAppConfig.cs" />
|
||||
<Compile Include="Config\WebConfigSections\ApplicationNameElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\AuthTimeoutCookieNameElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\ElementsRenderingElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\FileIconsElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\FileIconsElementCollection.cs" />
|
||||
<Compile Include="Config\WebConfigSections\OfficeOnlineElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\OfficeOnlineElementCollection.cs" />
|
||||
<Compile Include="Config\WebConfigSections\SessionKeysElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
|
||||
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
|
||||
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
||||
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
||||
<Compile Include="Exceptions\UnauthorizedException.cs" />
|
||||
<Compile Include="Exceptions\WebDavException.cs" />
|
||||
<Compile Include="Exceptions\WebDavHttpException.cs" />
|
||||
|
@ -49,6 +115,7 @@
|
|||
<Compile Include="IFolder.cs" />
|
||||
<Compile Include="IHierarchyItem.cs" />
|
||||
<Compile Include="IItemContent.cs" />
|
||||
<Compile Include="Interfaces\Security\IAuthenticationService.cs" />
|
||||
<Compile Include="IResource.cs" />
|
||||
<Compile Include="IResumableUpload.cs" />
|
||||
<Compile Include="ItemType.cs" />
|
||||
|
@ -56,9 +123,45 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Property.cs" />
|
||||
<Compile Include="PropertyName.cs" />
|
||||
<Compile Include="Resources\HttpErrors.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>HttpErrors.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\CryptoUtils.cs" />
|
||||
<Compile Include="Security\Cryptography\ICryptography.cs" />
|
||||
<Compile Include="Security\Authentication\FormsAuthenticationService.cs" />
|
||||
<Compile Include="Security\Authentication\Principals\WspPrincipal.cs" />
|
||||
<Compile Include="WebDavSession.cs" />
|
||||
<Compile Include="WspContext.cs" />
|
||||
<Compile Include="Wsp\Framework\WSP.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Interfaces\ActiveDirectory\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WebsitePanel.WebPortal\WebsitePanel.WebPortal.csproj">
|
||||
<Project>{C99EFB18-FFE7-45BB-8CA8-29336F3E8C68}</Project>
|
||||
<Name>WebsitePanel.WebPortal</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\HttpErrors.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>HttpErrors.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||
</Target>
|
||||
<!-- 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">
|
||||
|
|
|
@ -0,0 +1,287 @@
|
|||
// Copyright (c) 2015, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Microsoft.Web.Services3;
|
||||
using WebsitePanel.EnterpriseServer;
|
||||
using WebsitePanel.EnterpriseServer.HostedSolution;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||
using WebsitePanel.WebPortal;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Wsp.Framework
|
||||
{
|
||||
// WSP.Services
|
||||
|
||||
public class WSP
|
||||
{
|
||||
private readonly ICryptography _cryptography;
|
||||
|
||||
protected WSP()
|
||||
{
|
||||
_cryptography = DependencyResolver.Current.GetService<ICryptography>();
|
||||
}
|
||||
|
||||
public static WSP Services
|
||||
{
|
||||
get
|
||||
{
|
||||
WSP services = (WSP)HttpContext.Current.Items["WebServices"];
|
||||
|
||||
if (services == null)
|
||||
{
|
||||
services = new WSP();
|
||||
HttpContext.Current.Items["WebServices"] = services;
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
public esCRM CRM
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCachedProxy<esCRM>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public esVirtualizationServer VPS
|
||||
{
|
||||
get { return GetCachedProxy<esVirtualizationServer>(); }
|
||||
}
|
||||
|
||||
public esVirtualizationServerForPrivateCloud VPSPC
|
||||
{
|
||||
get { return GetCachedProxy<esVirtualizationServerForPrivateCloud>(); }
|
||||
}
|
||||
|
||||
public esBlackBerry BlackBerry
|
||||
{
|
||||
get { return GetCachedProxy<esBlackBerry>(); }
|
||||
}
|
||||
|
||||
public esOCS OCS
|
||||
{
|
||||
get { return GetCachedProxy<esOCS>(); }
|
||||
}
|
||||
|
||||
|
||||
public esLync Lync
|
||||
{
|
||||
get { return GetCachedProxy<esLync>(); }
|
||||
}
|
||||
|
||||
|
||||
public esOrganizations Organizations
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCachedProxy<esOrganizations>();
|
||||
}
|
||||
}
|
||||
|
||||
public esSystem System
|
||||
{
|
||||
get { return GetCachedProxy<esSystem>(); }
|
||||
}
|
||||
|
||||
public esApplicationsInstaller ApplicationsInstaller
|
||||
{
|
||||
get { return GetCachedProxy<esApplicationsInstaller>(); }
|
||||
}
|
||||
|
||||
public esWebApplicationGallery WebApplicationGallery
|
||||
{
|
||||
get { return GetCachedProxy<esWebApplicationGallery>(); }
|
||||
}
|
||||
|
||||
public esAuditLog AuditLog
|
||||
{
|
||||
get { return GetCachedProxy<esAuditLog>(); }
|
||||
}
|
||||
|
||||
public esAuthentication Authentication
|
||||
{
|
||||
get { return GetCachedProxy<esAuthentication>(false); }
|
||||
}
|
||||
|
||||
public esComments Comments
|
||||
{
|
||||
get { return GetCachedProxy<esComments>(); }
|
||||
}
|
||||
|
||||
public esDatabaseServers DatabaseServers
|
||||
{
|
||||
get { return GetCachedProxy<esDatabaseServers>(); }
|
||||
}
|
||||
|
||||
public esFiles Files
|
||||
{
|
||||
get { return GetCachedProxy<esFiles>(); }
|
||||
}
|
||||
|
||||
public esFtpServers FtpServers
|
||||
{
|
||||
get { return GetCachedProxy<esFtpServers>(); }
|
||||
}
|
||||
|
||||
public esMailServers MailServers
|
||||
{
|
||||
get { return GetCachedProxy<esMailServers>(); }
|
||||
}
|
||||
|
||||
public esOperatingSystems OperatingSystems
|
||||
{
|
||||
get { return GetCachedProxy<esOperatingSystems>(); }
|
||||
}
|
||||
|
||||
public esPackages Packages
|
||||
{
|
||||
get { return GetCachedProxy<esPackages>(); }
|
||||
}
|
||||
|
||||
public esScheduler Scheduler
|
||||
{
|
||||
get { return GetCachedProxy<esScheduler>(); }
|
||||
}
|
||||
|
||||
public esTasks Tasks
|
||||
{
|
||||
get { return GetCachedProxy<esTasks>(); }
|
||||
}
|
||||
|
||||
public esServers Servers
|
||||
{
|
||||
get { return GetCachedProxy<esServers>(); }
|
||||
}
|
||||
|
||||
public esStatisticsServers StatisticsServers
|
||||
{
|
||||
get { return GetCachedProxy<esStatisticsServers>(); }
|
||||
}
|
||||
|
||||
public esUsers Users
|
||||
{
|
||||
get { return GetCachedProxy<esUsers>(); }
|
||||
}
|
||||
|
||||
public esWebServers WebServers
|
||||
{
|
||||
get { return GetCachedProxy<esWebServers>(); }
|
||||
}
|
||||
|
||||
public esSharePointServers SharePointServers
|
||||
{
|
||||
get { return GetCachedProxy<esSharePointServers>(); }
|
||||
}
|
||||
|
||||
public esHostedSharePointServers HostedSharePointServers
|
||||
{
|
||||
get { return GetCachedProxy<esHostedSharePointServers>(); }
|
||||
}
|
||||
|
||||
public esImport Import
|
||||
{
|
||||
get { return GetCachedProxy<esImport>(); }
|
||||
}
|
||||
|
||||
public esBackup Backup
|
||||
{
|
||||
get { return GetCachedProxy<esBackup>(); }
|
||||
}
|
||||
|
||||
public esExchangeServer ExchangeServer
|
||||
{
|
||||
get { return GetCachedProxy<esExchangeServer>(); }
|
||||
}
|
||||
|
||||
|
||||
public esHeliconZoo HeliconZoo
|
||||
{
|
||||
get { return GetCachedProxy<esHeliconZoo>(); }
|
||||
}
|
||||
|
||||
|
||||
public esEnterpriseStorage EnterpriseStorage
|
||||
{
|
||||
get { return GetCachedProxy<esEnterpriseStorage>(); }
|
||||
}
|
||||
|
||||
public esRemoteDesktopServices RDS
|
||||
{
|
||||
get { return GetCachedProxy<esRemoteDesktopServices>(); }
|
||||
}
|
||||
|
||||
protected virtual T GetCachedProxy<T>()
|
||||
{
|
||||
return GetCachedProxy<T>(true);
|
||||
}
|
||||
|
||||
protected virtual T GetCachedProxy<T>(bool secureCalls)
|
||||
{
|
||||
Type t = typeof(T);
|
||||
string key = t.FullName + ".ServiceProxy";
|
||||
T proxy = (T)HttpContext.Current.Items[key];
|
||||
if (proxy == null)
|
||||
{
|
||||
proxy = (T)Activator.CreateInstance(t);
|
||||
HttpContext.Current.Items[key] = proxy;
|
||||
}
|
||||
|
||||
object p = proxy;
|
||||
|
||||
// configure proxy
|
||||
ConfigureEnterpriseServerProxy((WebServicesClientProtocol)p, secureCalls);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public void ConfigureEnterpriseServerProxy(WebServicesClientProtocol proxy, bool applyPolicy)
|
||||
{
|
||||
// load ES properties
|
||||
string serverUrl = PortalConfiguration.SiteSettings["EnterpriseServer"];
|
||||
|
||||
EnterpriseServerProxyConfigurator cnfg = new EnterpriseServerProxyConfigurator();
|
||||
cnfg.EnterpriseServerUrl = serverUrl;
|
||||
|
||||
// create assertion
|
||||
if (applyPolicy)
|
||||
{
|
||||
|
||||
cnfg.Username = WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Login;
|
||||
cnfg.Password = _cryptography.Decrypt(WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Password);
|
||||
}
|
||||
|
||||
cnfg.Configure(proxy);
|
||||
}
|
||||
}
|
||||
}
|
15
WebsitePanel/Sources/WebsitePanel.WebDav.Core/WspContext.cs
Normal file
15
WebsitePanel/Sources/WebsitePanel.WebDav.Core/WspContext.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core
|
||||
{
|
||||
public class WspContext
|
||||
{
|
||||
public static WspPrincipal User { get { return HttpContext.Current.User as WspPrincipal; } }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.2" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.2" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
</packages>
|
|
@ -8,7 +8,8 @@ namespace WebsitePanel.WebDavPortal
|
|||
public static void RegisterBundles(BundleCollection bundles)
|
||||
{
|
||||
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
|
||||
"~/Scripts/jquery-{version}.js"));
|
||||
"~/Scripts/jquery-{version}.js",
|
||||
"~/Scripts/jquery.cookie.js"));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
|
||||
"~/Scripts/jquery.validate*"));
|
||||
|
@ -24,7 +25,11 @@ namespace WebsitePanel.WebDavPortal
|
|||
|
||||
bundles.Add(new ScriptBundle("~/bundles/appScripts").Include(
|
||||
"~/Scripts/appScripts/recalculateResourseHeight.js",
|
||||
"~/Scripts/appScripts/uploadingData2.js"));
|
||||
"~/Scripts/appScripts/uploadingData2.js",
|
||||
"~/Scripts/appScripts/authentication.js"));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/authScripts").Include(
|
||||
"~/Scripts/appScripts/authentication.js"));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/css").Include(
|
||||
"~/Content/bootstrap.css",
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace WebsitePanel.WebDavPortal
|
|||
name: FileSystemRouteNames.FilePath,
|
||||
url: "{org}/{*pathPart}",
|
||||
defaults: new { controller = "FileSystem", action = "ShowContent", pathPart = UrlParameter.Optional },
|
||||
constraints: new { org = new WebsitePanel.WebDavPortal.Constraints.OrganizationRouteConstraint() }
|
||||
constraints: new { org = new Constraints.OrganizationRouteConstraint() }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDav.Core;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
|
@ -13,33 +13,22 @@ namespace WebsitePanel.WebDavPortal.Constraints
|
|||
{
|
||||
public class OrganizationRouteConstraint : IRouteConstraint
|
||||
{
|
||||
private static string actualOrgName;
|
||||
|
||||
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
|
||||
{
|
||||
var webdavManager = DependencyResolver.Current.GetService<IWebDavManager>();
|
||||
if (WspContext.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
object value;
|
||||
if (!values.TryGetValue(parameterName, out value))
|
||||
if (!values.TryGetValue(parameterName, out value))
|
||||
return false;
|
||||
|
||||
var str = value as string;
|
||||
if (str == null)
|
||||
return false;
|
||||
|
||||
if (routeDirection == RouteDirection.IncomingRequest)
|
||||
return actualOrgName == str;
|
||||
|
||||
if (httpContext.Session == null)
|
||||
if (str == null)
|
||||
return false;
|
||||
|
||||
if (webdavManager != null && str == webdavManager.OrganizationName)
|
||||
{
|
||||
actualOrgName = str;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return WspContext.User.OrganizationId == str;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,112 +1,60 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
using System.DirectoryServices;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
using Microsoft.Win32;
|
||||
using Ninject;
|
||||
using WebsitePanel.EnterpriseServer;
|
||||
using WebsitePanel.Portal;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDavPortal.Cryptography;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
using System.Web.Routing;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||
using WebsitePanel.WebDavPortal.Exceptions;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
using System.Collections.Generic;
|
||||
using WebsitePanel.Providers.OS;
|
||||
using WebDAV;
|
||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||
using WebsitePanel.WebDav.Core;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Controllers
|
||||
{
|
||||
public class AccountController : Controller
|
||||
{
|
||||
private readonly AccountModel _accountModel;
|
||||
private readonly IWebDavManager _webdavManager;
|
||||
private readonly ICryptography _cryptography;
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
|
||||
public AccountController(AccountModel accountModel, IWebDavManager webdavManager, ICryptography cryptography)
|
||||
public AccountController(ICryptography cryptography, IAuthenticationService authenticationService)
|
||||
{
|
||||
_accountModel = accountModel;
|
||||
_webdavManager = webdavManager;
|
||||
_cryptography = cryptography;
|
||||
_authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Login()
|
||||
{
|
||||
if (_accountModel != null)
|
||||
return RedirectToAction("ShowContent", "FileSystem");
|
||||
if (WspContext.User != null && WspContext.User.Identity.IsAuthenticated)
|
||||
{
|
||||
return RedirectToRoute(FileSystemRouteNames.FilePath, new { org = WspContext.User.OrganizationId });
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Login(AccountModel model)
|
||||
{
|
||||
AutheticationToServicesUsingWebsitePanelUser();
|
||||
var exchangeAccount = ES.Services.ExchangeServer.GetAccountByAccountNameWithoutItemId(model.Login);
|
||||
var isAuthenticated = exchangeAccount != null && exchangeAccount.AccountPassword == model.Password;
|
||||
|
||||
ViewBag.LdapIsAuthentication = isAuthenticated;
|
||||
var user = _authenticationService.LogIn(model.Login, model.Password);
|
||||
|
||||
if (isAuthenticated)
|
||||
ViewBag.LdapIsAuthentication = user.Identity.IsAuthenticated;
|
||||
|
||||
if (user.Identity.IsAuthenticated)
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ItemId] = exchangeAccount.ItemId;
|
||||
|
||||
model.Groups = ES.Services.Organizations.GetSecurityGroupsByMember(exchangeAccount.ItemId, exchangeAccount.AccountId);
|
||||
model.DisplayName = exchangeAccount.DisplayName;
|
||||
|
||||
WebDavManager manager = null;
|
||||
|
||||
try
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = model;
|
||||
|
||||
manager = new WebDavManager(new NetworkCredential(model.Login, model.Password, WebDavAppConfigManager.Instance.UserDomain), exchangeAccount.ItemId);
|
||||
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = manager;
|
||||
}
|
||||
catch (ConnectToWebDavServerException exception)
|
||||
{
|
||||
return View(new AccountModel { LdapError = exception.Message });
|
||||
}
|
||||
|
||||
return RedirectToAction("ShowContent", "FileSystem", new { org = manager.OrganizationName });
|
||||
return RedirectToRoute(FileSystemRouteNames.FilePath, new { org = WspContext.User.OrganizationId });
|
||||
}
|
||||
|
||||
return View(new AccountModel { LdapError = "The user name or password is incorrect" });
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Logout()
|
||||
{
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] = null;
|
||||
_authenticationService.LogOut();
|
||||
|
||||
return RedirectToRoute(AccountRouteNames.Login);
|
||||
}
|
||||
|
||||
private void AutheticationToServicesUsingWebsitePanelUser()
|
||||
{
|
||||
var websitePanelLogin = WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Login;
|
||||
var websitePanelPassword = _cryptography.Decrypt(WebDavAppConfigManager.Instance.WebsitePanelConstantUserParameters.Password);
|
||||
|
||||
var authTicket = new FormsAuthenticationTicket(1, websitePanelLogin, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout),
|
||||
FormsAuthentication.SlidingExpiration, websitePanelPassword + Environment.NewLine);
|
||||
var encryptedTicket = FormsAuthentication.Encrypt(authTicket);
|
||||
var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
|
||||
|
||||
if (FormsAuthentication.SlidingExpiration)
|
||||
{
|
||||
authCookie.Expires = authTicket.Expiration;
|
||||
}
|
||||
|
||||
Response.Cookies.Add(authCookie);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Web.Mvc;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Controllers
|
||||
|
|
|
@ -4,16 +4,13 @@ using System.Linq;
|
|||
using System.Net.Mime;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Ninject;
|
||||
using WebsitePanel.WebDav.Core;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Exceptions;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDavPortal.CustomAttributes;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
using WebsitePanel.WebDavPortal.Extensions;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
using WebsitePanel.Portal;
|
||||
using WebsitePanel.Providers.OS;
|
||||
using System.Net;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Controllers
|
||||
|
@ -33,7 +30,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
[HttpGet]
|
||||
public ActionResult ShowContent(string org, string pathPart = "")
|
||||
{
|
||||
if (org != _webdavManager.OrganizationName)
|
||||
if (org != WspContext.User.OrganizationId)
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
||||
|
||||
string fileName = pathPart.Split('/').Last();
|
||||
|
|
|
@ -10,18 +10,6 @@ namespace WebsitePanel.WebDavPortal.CustomAttributes
|
|||
{
|
||||
public class LdapAuthorizationAttribute : AuthorizeAttribute
|
||||
{
|
||||
protected override bool AuthorizeCore(HttpContextBase httpContext)
|
||||
{
|
||||
var accountInfo = DependencyResolver.Current.GetService<AccountModel>();
|
||||
|
||||
if (accountInfo == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
|
||||
{
|
||||
filterContext.Result = new RedirectToRouteResult(AccountRouteNames.Login, null);
|
||||
|
|
|
@ -4,7 +4,10 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.SessionState;
|
||||
using WebsitePanel.WebDavPortal.Cryptography;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||
using WebsitePanel.WebDav.Core.Security;
|
||||
using WebsitePanel.WebDav.Core.Security.Authentication;
|
||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection.Providers;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
|
@ -12,12 +15,12 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection
|
|||
{
|
||||
public class PortalDependencies
|
||||
{
|
||||
public static void Configure(IKernel kernerl)
|
||||
public static void Configure(IKernel kernel)
|
||||
{
|
||||
kernerl.Bind<HttpSessionState>().ToProvider<HttpSessionStateProvider>();
|
||||
kernerl.Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
||||
kernerl.Bind<AccountModel>().ToProvider<AccountInfoProvider>();
|
||||
kernerl.Bind<ICryptography>().To<CryptoUtils>();
|
||||
kernel.Bind<HttpSessionState>().ToProvider<HttpSessionStateProvider>();
|
||||
kernel.Bind<ICryptography>().To<CryptoUtils>();
|
||||
kernel.Bind<IAuthenticationService>().To<FormsAuthenticationService>();
|
||||
kernel.Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
using System.Web.SessionState;
|
||||
using Ninject;
|
||||
using Ninject.Activation;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
||||
{
|
||||
public class AccountInfoProvider : Provider<AccountModel>
|
||||
{
|
||||
protected override AccountModel CreateInstance(IContext context)
|
||||
{
|
||||
var session = context.Kernel.Get<HttpSessionState>();
|
||||
|
||||
AccountModel accountInfo = null;
|
||||
|
||||
if (session != null)
|
||||
{
|
||||
accountInfo = session[WebDavAppConfigManager.Instance.SessionKeys.AccountInfo] as AccountModel;
|
||||
}
|
||||
|
||||
return accountInfo;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,11 @@
|
|||
using System.Web.SessionState;
|
||||
using System.Net;
|
||||
using System.Web.SessionState;
|
||||
using Ninject;
|
||||
using Ninject.Activation;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDav.Core;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||
using WebsitePanel.WebDavPortal.Exceptions;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
||||
|
@ -17,6 +21,15 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection.Providers
|
|||
if (session != null)
|
||||
{
|
||||
webDavManager = session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] as WebDavManager;
|
||||
|
||||
if (webDavManager == null)
|
||||
{
|
||||
var cryptography = context.Kernel.Get<ICryptography>();
|
||||
|
||||
webDavManager = new WebDavManager(cryptography);
|
||||
|
||||
session[WebDavAppConfigManager.Instance.SessionKeys.WebDavManager] = webDavManager;
|
||||
}
|
||||
}
|
||||
|
||||
return webDavManager;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDavPortal.Extensions;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.FileOperations
|
||||
|
|
|
@ -3,6 +3,10 @@ using System.Web;
|
|||
using System.Web.Mvc;
|
||||
using System.Web.Optimization;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Security;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||
using WebsitePanel.WebDavPortal.Controllers;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
|
||||
|
@ -48,5 +52,47 @@ namespace WebsitePanel.WebDavPortal
|
|||
controller.Execute(requestContext);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
|
||||
{
|
||||
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
|
||||
var contextWrapper = new HttpContextWrapper(Context);
|
||||
|
||||
if (authCookie != null)
|
||||
{
|
||||
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
|
||||
|
||||
var serializer = new JavaScriptSerializer();
|
||||
|
||||
var principalSerialized = serializer.Deserialize<WspPrincipal>(authTicket.UserData);
|
||||
|
||||
var principal = new WspPrincipal(principalSerialized.Login);
|
||||
|
||||
principal.AccountId = principalSerialized.AccountId;
|
||||
principal.ItemId = principalSerialized.ItemId;
|
||||
principal.OrganizationId = principalSerialized.OrganizationId;
|
||||
principal.DisplayName = principalSerialized.DisplayName;
|
||||
principal.EncryptedPassword = principalSerialized.EncryptedPassword;
|
||||
|
||||
HttpContext.Current.User = principal;
|
||||
|
||||
if (!contextWrapper.Request.IsAjaxRequest())
|
||||
{
|
||||
SetAuthenticationExpirationTicket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetAuthenticationExpirationTicket()
|
||||
{
|
||||
var expirationDateTimeInUtc = DateTime.UtcNow.AddMinutes(FormsAuthentication.Timeout.TotalMinutes).AddSeconds(1);
|
||||
var authenticationExpirationTicketCookie = new HttpCookie(WebDavAppConfigManager.Instance.AuthTimeoutCookieName);
|
||||
|
||||
authenticationExpirationTicketCookie.Value = expirationDateTimeInUtc.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString("F0");
|
||||
authenticationExpirationTicketCookie.HttpOnly = false;
|
||||
authenticationExpirationTicketCookie.Secure = FormsAuthentication.RequireSSL;
|
||||
|
||||
HttpContext.Current.Response.Cookies.Add(authenticationExpirationTicketCookie);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,18 +15,6 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
[Display(Name = @"Password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrEmpty(Login) ? Login.Split('@')[0] : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public IEnumerable<ExchangeAccount> Groups { get; set; }
|
||||
|
||||
public string LdapError { get; set; }
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
public interface IWebDavManager
|
||||
{
|
||||
string RootPath { get; }
|
||||
string OrganizationName { get; }
|
||||
void OpenFolder(string pathPart);
|
||||
IEnumerable<IHierarchyItem> GetChildren();
|
||||
bool IsFile(string fileName);
|
||||
|
|
|
@ -4,10 +4,12 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using WebsitePanel.WebDav.Core;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDavPortal.Config;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||
using WebsitePanel.WebDav.Core.Wsp.Framework;
|
||||
using WebsitePanel.WebDavPortal.Exceptions;
|
||||
using WebsitePanel.Portal;
|
||||
using WebsitePanel.Providers.OS;
|
||||
using Ninject;
|
||||
using WebsitePanel.WebDavPortal.DependencyInjection;
|
||||
|
@ -18,15 +20,14 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
{
|
||||
public class WebDavManager : IWebDavManager
|
||||
{
|
||||
private readonly WebDavSession _webDavSession = new WebDavSession();
|
||||
private readonly ICryptography _cryptography;
|
||||
private readonly WebDavSession _webDavSession;
|
||||
|
||||
private readonly AccountModel _accountModel;
|
||||
private readonly ILog Log;
|
||||
|
||||
private IList<SystemFile> _rootFolders;
|
||||
private int _itemId;
|
||||
private IFolder _currentFolder;
|
||||
private string _organizationName;
|
||||
private string _webDavRootPath;
|
||||
private bool _isRoot = true;
|
||||
|
||||
|
@ -35,26 +36,24 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
get { return _webDavRootPath; }
|
||||
}
|
||||
|
||||
public string OrganizationName
|
||||
public WebDavManager(ICryptography cryptography)
|
||||
{
|
||||
get { return _organizationName; }
|
||||
}
|
||||
|
||||
public WebDavManager(NetworkCredential credential, int itemId)
|
||||
{
|
||||
_accountModel = DependencyResolver.Current.GetService<AccountModel>();
|
||||
_cryptography = cryptography;
|
||||
Log = LogManager.GetLogger(this.GetType());
|
||||
|
||||
var credential = new NetworkCredential(WspContext.User.Login, _cryptography.Decrypt(WspContext.User.EncryptedPassword), WebDavAppConfigManager.Instance.UserDomain);
|
||||
|
||||
_webDavSession = new WebDavSession();
|
||||
|
||||
_webDavSession.Credentials = credential;
|
||||
_itemId = itemId;
|
||||
_rootFolders = ConnectToWebDavServer(_accountModel);
|
||||
_itemId = WspContext.User.ItemId;
|
||||
_rootFolders = ConnectToWebDavServer();
|
||||
|
||||
if (_rootFolders.Any())
|
||||
{
|
||||
var folder = _rootFolders.First();
|
||||
var uri = new Uri(folder.Url);
|
||||
_webDavRootPath = uri.Scheme + "://" + uri.Host + uri.Segments[0] + uri.Segments[1];
|
||||
_organizationName = uri.Segments[1].Trim('/');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,19 +132,22 @@ namespace WebsitePanel.WebDavPortal.Models
|
|||
}
|
||||
}
|
||||
|
||||
private IList<SystemFile> ConnectToWebDavServer(AccountModel user)
|
||||
private IList<SystemFile> ConnectToWebDavServer()
|
||||
{
|
||||
var rootFolders = new List<SystemFile>();
|
||||
var user = WspContext.User;
|
||||
|
||||
foreach (var folder in ES.Services.EnterpriseStorage.GetEnterpriseFolders(_itemId))
|
||||
var userGroups = WSP.Services.Organizations.GetSecurityGroupsByMember(user.ItemId, user.AccountId);
|
||||
|
||||
foreach (var folder in WSP.Services.EnterpriseStorage.GetEnterpriseFolders(_itemId))
|
||||
{
|
||||
var permissions = ES.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(_itemId, folder.Name);
|
||||
var permissions = WSP.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(_itemId, folder.Name);
|
||||
|
||||
foreach (var permission in permissions)
|
||||
{
|
||||
if ((!permission.IsGroup
|
||||
&& (permission.DisplayName == user.UserName || permission.DisplayName == user.DisplayName))
|
||||
|| (permission.IsGroup && user.Groups.Any(x=> x.DisplayName == permission.DisplayName)))
|
||||
|| (permission.IsGroup && userGroups.Any(x => x.DisplayName == permission.DisplayName)))
|
||||
{
|
||||
rootFolders.Add(folder);
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
function CheckAuthenticationExpiration(authcookieName, logoutUrl) {
|
||||
var c = $.cookie(authcookieName);
|
||||
|
||||
if (c != null && c != "" && !isNaN(c)) {
|
||||
var now = new Date();
|
||||
var ms = parseInt(c, 10);
|
||||
var expiration = new Date().setTime(ms);
|
||||
if (now > expiration) {
|
||||
window.location.replace(logoutUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function StartAuthExpirationCheckTimer(authcookieName, logoutUrl) {
|
||||
setInterval(function() {
|
||||
CheckAuthenticationExpiration(authcookieName, logoutUrl);
|
||||
}, 20000);
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*!
|
||||
* jQuery Cookie Plugin v1.4.0
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2013 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else {
|
||||
// Browser globals.
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function encode(s) {
|
||||
return config.raw ? s : encodeURIComponent(s);
|
||||
}
|
||||
|
||||
function decode(s) {
|
||||
return config.raw ? s : decodeURIComponent(s);
|
||||
}
|
||||
|
||||
function stringifyCookieValue(value) {
|
||||
return encode(config.json ? JSON.stringify(value) : String(value));
|
||||
}
|
||||
|
||||
function parseCookieValue(s) {
|
||||
if (s.indexOf('"') === 0) {
|
||||
// This is a quoted cookie as according to RFC2068, unescape...
|
||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
try {
|
||||
// Replace server-side written pluses with spaces.
|
||||
// If we can't decode the cookie, ignore it, it's unusable.
|
||||
s = decodeURIComponent(s.replace(pluses, ' '));
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// If we can't parse the cookie, ignore it, it's unusable.
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function read(s, converter) {
|
||||
var value = config.raw ? s : parseCookieValue(s);
|
||||
return $.isFunction(converter) ? converter(value) : value;
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// Write
|
||||
if (value !== undefined && !$.isFunction(value)) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setDate(t.getDate() + days);
|
||||
}
|
||||
|
||||
return (document.cookie = [
|
||||
encode(key), '=', stringifyCookieValue(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// Read
|
||||
|
||||
var result = key ? undefined : {};
|
||||
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all. Also prevents odd result when
|
||||
// calling $.cookie().
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = decode(parts.shift());
|
||||
var cookie = parts.join('=');
|
||||
|
||||
if (key && key === name) {
|
||||
// If second argument (value) is a function it's a converter...
|
||||
result = read(cookie, value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Prevent storing a cookie that we couldn't decode.
|
||||
if (!key && (cookie = read(cookie)) !== undefined) {
|
||||
result[name] = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) !== undefined) {
|
||||
// Must not alter options, thus extending a fresh object...
|
||||
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
}));
|
|
@ -5,4 +5,6 @@
|
|||
<br/>
|
||||
<h4 id="errorMessage">
|
||||
@Html.Raw(Model.Message)
|
||||
|
||||
@Html.Raw(Model.Exception)
|
||||
</h4>
|
|
@ -1,6 +1,7 @@
|
|||
@using WebsitePanel.WebDav.Core.Client
|
||||
@using WebsitePanel.WebDav.Core
|
||||
@using WebsitePanel.WebDav.Core.Client
|
||||
@using Ninject
|
||||
@using WebsitePanel.WebDavPortal.Config
|
||||
@using WebsitePanel.WebDav.Core.Config
|
||||
|
||||
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
|
||||
@{
|
||||
|
@ -24,7 +25,7 @@ else
|
|||
<div class="container">
|
||||
@if (Model != null)
|
||||
{
|
||||
string header = webDavManager.OrganizationName;
|
||||
string header = WspContext.User.OrganizationId;
|
||||
<a href="/@header/" class="btn btn-primary btn-sm active" role="button">@header</a>
|
||||
string[] elements = Model.UrlSuffix.Split(new[] {"/"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < elements.Length; i++)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
@using WebsitePanel.WebDav.Core.Client
|
||||
@using WebsitePanel.WebDavPortal.Config
|
||||
@using WebsitePanel.WebDav.Core.Config
|
||||
@using WebsitePanel.WebDavPortal.FileOperations
|
||||
@using Ninject;
|
||||
@model IHierarchyItem
|
||||
|
||||
@{
|
||||
string actualPath = Model.ItemType == ItemType.Folder ? "~/Content/Images/folder_100x100.png" : WebDavAppConfigManager.Instance.FileIcons[Path.GetExtension(Model.DisplayName.Trim('/'))];
|
||||
string name = Model.ItemType == ItemType.Folder ? Model.DisplayName.Trim('/') : Model.DisplayName;
|
||||
string name = Model.DisplayName.Trim('/');
|
||||
var opener = new FileOpenerManager()[Path.GetExtension(Model.DisplayName)];
|
||||
bool isTargetBlank;
|
||||
string href = "/";
|
||||
|
@ -23,7 +23,7 @@
|
|||
}
|
||||
}
|
||||
<div class="col-sm-2 element-container">
|
||||
<a href="@href" @Html.Raw(isTargetBlank ? "target=\"_blank\"" : string.Empty) title="@Model.DisplayName.Trim('/')">
|
||||
<a href="@href" @Html.Raw(isTargetBlank ? "target=\"_blank\"" : string.Empty) title="@name">
|
||||
<img class="icon-size" src="@Url.Content(actualPath)" />
|
||||
<p style="word-wrap: break-word;">@name</p>
|
||||
</a>
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
@using Ninject
|
||||
@using WebsitePanel.WebDavPortal.Config
|
||||
@using WebsitePanel.WebDav.Core
|
||||
@using WebsitePanel.WebDav.Core.Config
|
||||
@using WebsitePanel.WebDavPortal.DependencyInjection
|
||||
@using WebsitePanel.WebDavPortal.Models
|
||||
@using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
@{
|
||||
var account = DependencyResolver.Current.GetService<AccountModel>();
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -30,10 +27,10 @@
|
|||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
@{
|
||||
if (account != null)
|
||||
if (WspContext.User != null)
|
||||
{
|
||||
<a id="logout" class="nav navbar-text navbar-right" href="@Url.RouteUrl(AccountRouteNames.Logout)" title="Log out"><i class="glyphicon glyphicon-log-out"></i></a>
|
||||
<h4 id="username" class="nav navbar-text navbar-right">@account.Login</h4>
|
||||
<h4 id="username" class="nav navbar-text navbar-right">@WspContext.User.Login</h4>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
@ -45,6 +42,18 @@
|
|||
|
||||
@Scripts.Render("~/bundles/jquery")
|
||||
@Scripts.Render("~/bundles/bootstrap")
|
||||
|
||||
@if (WspContext.User != null)
|
||||
{
|
||||
@Scripts.Render("~/bundles/authScripts")
|
||||
|
||||
<script>
|
||||
StartAuthExpirationCheckTimer("@WebDavAppConfigManager.Instance.AuthTimeoutCookieName", "@Url.RouteUrl(AccountRouteNames.Logout)");
|
||||
</script>
|
||||
}
|
||||
|
||||
@RenderSection("scripts", required: false)
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<webDavExplorerConfigurationSettings>
|
||||
<!--<userDomain value=""/>-->
|
||||
<applicationName value="WebDAV Explorer" />
|
||||
<authTimeoutCookieName value=".auth-logout-timeout" />
|
||||
<elementsRendering defaultCount="20" addElementsCount="20" elementsToIgnoreKey="web.config" />
|
||||
<websitePanelConstantUser login="serveradmin" password="HtR7J8dtBhovYLigXNtVutxqpvaE48Z+FBIokWZlR/g=" />
|
||||
<sessionKeys>
|
||||
|
|
|
@ -137,31 +137,14 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_GlobalResources\Resource.errors.designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resource.errors.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="App_Start\BundleConfig.cs" />
|
||||
<Compile Include="App_Start\FilterConfig.cs" />
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="Config\Entities\AbstractConfigCollection.cs" />
|
||||
<Compile Include="Config\Entities\ElementsRendering.cs" />
|
||||
<Compile Include="Config\Entities\FileIconsDictionary.cs" />
|
||||
<Compile Include="Config\Entities\HttpErrorsCollection.cs" />
|
||||
<Compile Include="Config\Entities\OfficeOnlineCollection.cs" />
|
||||
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
|
||||
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
|
||||
<Compile Include="Config\IWebDavAppConfig.cs" />
|
||||
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
||||
<Compile Include="Constraints\OrganizationRouteConstraint.cs" />
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Controllers\ErrorController.cs" />
|
||||
<Compile Include="Controllers\FileSystemController.cs" />
|
||||
<Compile Include="Cryptography\CryptoUtils.cs" />
|
||||
<Compile Include="Cryptography\ICryptography.cs" />
|
||||
<Compile Include="CustomAttributes\LdapAuthorizationAttribute.cs" />
|
||||
<Compile Include="DependencyInjection\Providers\AccountInfoProvider.cs" />
|
||||
<Compile Include="DependencyInjection\NinjectDependecyResolver.cs" />
|
||||
<Compile Include="DependencyInjection\PortalDependencies.cs" />
|
||||
<Compile Include="DependencyInjection\Providers\HttpSessionStateProvider.cs" />
|
||||
|
@ -186,17 +169,6 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI\Routes\AccountRouteNames.cs" />
|
||||
<Compile Include="UI\Routes\FileSystemRouteNames.cs" />
|
||||
<Compile Include="WebConfigSections\ApplicationNameElement.cs" />
|
||||
<Compile Include="WebConfigSections\ElementsRenderingElement.cs" />
|
||||
<Compile Include="WebConfigSections\FileIconsElement.cs" />
|
||||
<Compile Include="WebConfigSections\FileIconsElementCollection.cs" />
|
||||
<Compile Include="WebConfigSections\OfficeOnlineElement.cs" />
|
||||
<Compile Include="WebConfigSections\OfficeOnlineElementCollection.cs" />
|
||||
<Compile Include="WebConfigSections\SessionKeysElement.cs" />
|
||||
<Compile Include="WebConfigSections\SessionKeysElementCollection.cs" />
|
||||
<Compile Include="WebConfigSections\UserDomainElement.cs" />
|
||||
<Compile Include="WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
|
||||
<Compile Include="WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\bootstrap-theme.css" />
|
||||
|
@ -248,6 +220,7 @@
|
|||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="Scripts\jquery-2.1.1.intellisense.js" />
|
||||
<Content Include="Scripts\appScripts\authentication.js" />
|
||||
<Content Include="Scripts\appScripts\recalculateResourseHeight.js" />
|
||||
<Content Include="Scripts\appScripts\uploadingData2.js" />
|
||||
<Content Include="Scripts\bootstrap.js" />
|
||||
|
@ -256,6 +229,7 @@
|
|||
<Content Include="Scripts\jquery-2.1.1.min.js" />
|
||||
<Content Include="Scripts\jquery-2.1.1.min.map" />
|
||||
<None Include="Scripts\jquery.validate-vsdoc.js" />
|
||||
<Content Include="Scripts\jquery.cookie.js" />
|
||||
<Content Include="Scripts\jquery.validate.js" />
|
||||
<Content Include="Scripts\jquery.validate.min.js" />
|
||||
<Content Include="Scripts\jquery.validate.unobtrusive.js" />
|
||||
|
@ -292,22 +266,11 @@
|
|||
<Content Include="packages.config" />
|
||||
<None Include="Project_Readme.html" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App_GlobalResources\Resource.errors.resx">
|
||||
<Generator>GlobalResourceProxyGenerator</Generator>
|
||||
<LastGenOutput>Resource.errors.designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WebsitePanel.WebDav.Core\WebsitePanel.WebDav.Core.csproj">
|
||||
<Project>{BA147805-9EF1-45F2-BF32-A5825D4E950D}</Project>
|
||||
<Name>WebsitePanel.WebDav.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebsitePanel.WebPortal\DesktopModules\WebsitePanel\WebsitePanel.Portal.Modules.csproj">
|
||||
<Project>{12232731-5C45-4ED6-98F8-D47ABE728280}</Project>
|
||||
<Name>WebsitePanel.Portal.Modules</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
|
||||
<package id="bootstrap" version="3.3.0" targetFramework="net45" />
|
||||
<package id="jQuery" version="2.1.1" targetFramework="net45" />
|
||||
<package id="jQuery.Cookie" version="1.4.0" targetFramework="net45" />
|
||||
<package id="jQuery.Validation" version="1.13.1" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.0" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.2" targetFramework="net45" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue