webdav portal password reset added
This commit is contained in:
parent
4bae47e17f
commit
599e9a8865
48 changed files with 1163 additions and 117 deletions
|
@ -65,6 +65,16 @@ namespace WebsitePanel.WebDav.Core.Config.Entities
|
|||
}
|
||||
}
|
||||
|
||||
public string PasswordResetSmsKey
|
||||
{
|
||||
get
|
||||
{
|
||||
SessionKeysElement sessionKey =
|
||||
_sessionKeys.FirstOrDefault(x => x.Key == SessionKeysElement.PassswordResetSmsKey);
|
||||
return sessionKey != null ? sessionKey.Value : null;
|
||||
}
|
||||
}
|
||||
|
||||
public string ResourseRenderCount
|
||||
{
|
||||
get
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||
{
|
||||
public class TwilioParameters: AbstractConfigCollection
|
||||
{
|
||||
public string AccountSid { get; private set; }
|
||||
public string AuthorizationToken { get; private set; }
|
||||
public string PhoneFrom { get; private set; }
|
||||
|
||||
public TwilioParameters()
|
||||
{
|
||||
AccountSid = ConfigSection.Twilio.AccountSid;
|
||||
AuthorizationToken = ConfigSection.Twilio.AuthorizationToken;
|
||||
PhoneFrom = ConfigSection.Twilio.PhoneFrom;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ namespace WebsitePanel.WebDav.Core.Config
|
|||
string ApplicationName { get; }
|
||||
ElementsRendering ElementsRendering { get; }
|
||||
WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; }
|
||||
TwilioParameters TwilioParameters { get; }
|
||||
SessionKeysCollection SessionKeys { get; }
|
||||
FileIconsDictionary FileIcons { get; }
|
||||
HttpErrorsCollection HttpErrors { get; }
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
|||
public const string WebDavManagerKey = "WebDavManagerSessionKey";
|
||||
public const string UserGroupsKey = "UserGroupsKey";
|
||||
public const string WebDavRootFolderPermissionsKey = "WebDavRootFolderPermissionsKey";
|
||||
public const string PassswordResetSmsKey = "PassswordResetSmsKey";
|
||||
public const string ResourseRenderCountKey = "ResourseRenderCountSessionKey";
|
||||
public const string ItemIdSessionKey = "ItemId";
|
||||
public const string OwaEditFoldersSessionKey = "OwaEditFoldersSession";
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||
{
|
||||
public class TwilioElement : ConfigurationElement
|
||||
{
|
||||
private const string AccountSidPropName = "accountSid";
|
||||
private const string AuthorizationTokenPropName = "authorizationToken";
|
||||
private const string PhoneFromPropName = "phoneFrom";
|
||||
|
||||
[ConfigurationProperty(AccountSidPropName, IsKey = true, IsRequired = true)]
|
||||
public string AccountSid
|
||||
{
|
||||
get { return this[AccountSidPropName].ToString(); }
|
||||
set { this[AccountSidPropName] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(AuthorizationTokenPropName, IsKey = true, IsRequired = true)]
|
||||
public string AuthorizationToken
|
||||
{
|
||||
get { return this[AuthorizationTokenPropName].ToString(); }
|
||||
set { this[AuthorizationTokenPropName] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(PhoneFromPropName, IsKey = true, IsRequired = true)]
|
||||
public string PhoneFrom
|
||||
{
|
||||
get { return this[PhoneFromPropName].ToString(); }
|
||||
set { this[PhoneFromPropName] = value; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
private const string OfficeOnlineKey = "officeOnline";
|
||||
private const string FilesToIgnoreKey = "filesToIgnore";
|
||||
private const string TypeOpenerKey = "typeOpener";
|
||||
private const string TwilioKey = "twilio";
|
||||
|
||||
public const string SectionName = "webDavExplorerConfigurationSettings";
|
||||
|
||||
|
@ -65,6 +66,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
set { this[WebsitePanelConstantUserKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(TwilioKey, IsRequired = true)]
|
||||
public TwilioElement Twilio
|
||||
{
|
||||
get { return (TwilioElement)this[TwilioKey]; }
|
||||
set { this[TwilioKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ElementsRenderingKey, IsRequired = true)]
|
||||
public ElementsRenderingElement ElementsRendering
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace WebsitePanel.WebDav.Core.Config
|
|||
OwaSupportedBrowsers = new OwaSupportedBrowsersCollection();
|
||||
FilesToIgnore = new FilesToIgnoreCollection();
|
||||
FileOpener = new OpenerCollection();
|
||||
TwilioParameters = new TwilioParameters();
|
||||
}
|
||||
|
||||
public static WebDavAppConfigManager Instance
|
||||
|
@ -55,6 +56,7 @@ namespace WebsitePanel.WebDav.Core.Config
|
|||
|
||||
public ElementsRendering ElementsRendering { get; private set; }
|
||||
public WebsitePanelConstantUserParameters WebsitePanelConstantUserParameters { get; private set; }
|
||||
public TwilioParameters TwilioParameters { get; private set; }
|
||||
public SessionKeysCollection SessionKeys { get; private set; }
|
||||
public FileIconsDictionary FileIcons { get; private set; }
|
||||
public HttpErrorsCollection HttpErrors { get; private set; }
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Interfaces.Security
|
||||
{
|
||||
public interface ISmsAuthenticationService
|
||||
{
|
||||
bool VerifyResponse(Guid token, string response);
|
||||
string SendRequestMessage(string phoneTo);
|
||||
string GenerateResponse();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace WebsitePanel.WebDav.Core.Interfaces.Services
|
||||
{
|
||||
public interface ISmsDistributionService
|
||||
{
|
||||
void SendMessage(string phoneFrom, string phone, string message);
|
||||
|
||||
void SendMessage(string phone, string message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Services;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Security.Authentication
|
||||
{
|
||||
public class SmsAuthenticationService : ISmsAuthenticationService
|
||||
{
|
||||
private ISmsDistributionService _smsService;
|
||||
|
||||
public SmsAuthenticationService(ISmsDistributionService smsService)
|
||||
{
|
||||
_smsService = smsService;
|
||||
}
|
||||
|
||||
public bool VerifyResponse( Guid token, string response)
|
||||
{
|
||||
var accessToken = WspContext.Services.Organizations.GetPasswordresetAccessToken(token);
|
||||
|
||||
if (accessToken == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return string.Compare(accessToken.SmsResponse, response, StringComparison.InvariantCultureIgnoreCase) == 0;
|
||||
}
|
||||
|
||||
public string SendRequestMessage(string phoneTo)
|
||||
{
|
||||
var response = GenerateResponse();
|
||||
|
||||
_smsService.SendMessage(WebDavAppConfigManager.Instance.TwilioParameters.PhoneFrom, phoneTo, response);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public string GenerateResponse()
|
||||
{
|
||||
var random = new Random(Guid.NewGuid().GetHashCode());
|
||||
|
||||
return random.Next(10000, 99999).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using Twilio;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Services;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Services
|
||||
{
|
||||
public class TwillioSmsDistributionService : ISmsDistributionService
|
||||
{
|
||||
private TwilioRestClient _twilioRestClient { get; set; }
|
||||
|
||||
public TwillioSmsDistributionService()
|
||||
{
|
||||
_twilioRestClient = new TwilioRestClient(WebDavAppConfigManager.Instance.TwilioParameters.AccountSid, WebDavAppConfigManager.Instance.TwilioParameters.AuthorizationToken);
|
||||
}
|
||||
|
||||
|
||||
public void SendMessage(string phoneFrom, string phone, string message)
|
||||
{
|
||||
_twilioRestClient.SendSmsMessage(phoneFrom, phone, message);
|
||||
}
|
||||
|
||||
public void SendMessage(string phone, string message)
|
||||
{
|
||||
_twilioRestClient.SendSmsMessage(WebDavAppConfigManager.Instance.TwilioParameters.PhoneFrom, phone, message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,9 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Bin\Microsoft.Web.Services3.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
|
@ -87,6 +90,10 @@
|
|||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Twilio.Api">
|
||||
<HintPath>..\packages\Twilio.3.6.29\lib\3.5\Twilio.Api.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="WebsitePanel.EnterpriseServer.Base">
|
||||
<HintPath>..\..\Bin\WebsitePanel.EnterpriseServer.Base.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -108,6 +115,7 @@
|
|||
<Compile Include="Config\Entities\OwaSupportedBrowsersCollection.cs" />
|
||||
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
|
||||
<Compile Include="Config\Entities\OpenerCollection.cs" />
|
||||
<Compile Include="Config\Entities\TwilioParameters.cs" />
|
||||
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
|
||||
<Compile Include="Config\IWebDavAppConfig.cs" />
|
||||
<Compile Include="Config\WebConfigSections\ApplicationNameElement.cs" />
|
||||
|
@ -126,6 +134,7 @@
|
|||
<Compile Include="Config\WebConfigSections\SessionKeysElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
|
||||
<Compile Include="Config\WebConfigSections\OpenerElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\TwilioElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
|
||||
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
|
||||
<Compile Include="Config\WebConfigSections\WebdavRootElement.cs" />
|
||||
|
@ -149,6 +158,9 @@
|
|||
<Compile Include="IHierarchyItem.cs" />
|
||||
<Compile Include="IItemContent.cs" />
|
||||
<Compile Include="Interfaces\Managers\Users\IUserSettingsManager.cs" />
|
||||
<Compile Include="Interfaces\Security\ISmsAuthenticationService.cs" />
|
||||
<Compile Include="Security\Authentication\SmsAuthenticationService.cs" />
|
||||
<Compile Include="Interfaces\Services\ISmsDistributionService.cs" />
|
||||
<Compile Include="Interfaces\Storages\IKeyValueStorage.cs" />
|
||||
<Compile Include="Interfaces\Storages\ITtlStorage.cs" />
|
||||
<Compile Include="Managers\Users\UserSettingsManager.cs" />
|
||||
|
@ -188,6 +200,7 @@
|
|||
<Compile Include="Security\Authentication\FormsAuthenticationService.cs" />
|
||||
<Compile Include="Security\Authentication\Principals\WspPrincipal.cs" />
|
||||
<Compile Include="Owa\WopiServer.cs" />
|
||||
<Compile Include="Services\TwillioSmsDistributionService.cs" />
|
||||
<Compile Include="Storages\CacheTtlStorage.cs" />
|
||||
<Compile Include="WebDavSession.cs" />
|
||||
<Compile Include="WspContext.cs" />
|
||||
|
|
|
@ -5,4 +5,6 @@
|
|||
<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" />
|
||||
<package id="RestSharp" version="105.0.1" targetFramework="net45" />
|
||||
<package id="Twilio" version="3.6.29" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Add table
Add a link
Reference in a new issue