webdav portal login + access token fix
This commit is contained in:
parent
1c3f10a30a
commit
213eaf0077
19 changed files with 1431 additions and 1181 deletions
|
@ -4,6 +4,7 @@ using System.Threading;
|
|||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Security;
|
||||
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||
|
@ -58,24 +59,6 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
|
|||
return principal;
|
||||
}
|
||||
|
||||
public WspPrincipal LogIn(string accessToken)
|
||||
{
|
||||
var token = _cryptography.Decrypt(accessToken.Replace("AAAAA", "/"));
|
||||
|
||||
var splitResult = token.Split(':');
|
||||
|
||||
var login = splitResult[0];
|
||||
var password = _cryptography.Decrypt(splitResult[1]);
|
||||
var expiration = DateTime.Parse(splitResult[2]);
|
||||
|
||||
if (expiration < DateTime.Today)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return LogIn(login, password);
|
||||
}
|
||||
|
||||
public void CreateAuthenticationTicket(WspPrincipal principal)
|
||||
{
|
||||
var serializer = new JavaScriptSerializer();
|
||||
|
@ -96,13 +79,6 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
|
|||
HttpContext.Current.Response.Cookies.Add(cookie);
|
||||
}
|
||||
|
||||
public string CreateAccessToken(WspPrincipal principal)
|
||||
{
|
||||
var token = string.Format("{0}:{1}:{2}", principal.Login, principal.EncryptedPassword, DateTime.Now.ToShortDateString());
|
||||
|
||||
return _cryptography.Encrypt(token).Replace("/", "AAAAA");
|
||||
}
|
||||
|
||||
public void LogOut()
|
||||
{
|
||||
FormsAuthentication.SignOut();
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication.Principals
|
|||
public int ItemId { get; set; }
|
||||
|
||||
public string Login { get; set; }
|
||||
public string EncryptedPassword { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
|
@ -27,6 +26,8 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication.Principals
|
|||
[XmlIgnore, ScriptIgnore]
|
||||
public IIdentity Identity { get; private set; }
|
||||
|
||||
public string EncryptedPassword { get; set; }
|
||||
|
||||
public WspPrincipal(string username)
|
||||
{
|
||||
Identity = new GenericIdentity(username);//new WindowsIdentity(username, "WindowsAuthentication");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue