U4-7863 Remove Nuget requirement: Microsoft.Net.Http - this is not used, nor is it required (it also installs a bunch of other packages we don't need)

This commit is contained in:
Shannon
2016-02-03 10:14:53 +01:00
parent ee303957b8
commit 08e9579481
8 changed files with 10 additions and 104 deletions

View File

@@ -167,74 +167,18 @@ namespace Umbraco.Core.Security
/// This clears the forms authentication cookie for webapi since cookies are handled differently
/// </summary>
/// <param name="response"></param>
[Obsolete("Use OWIN IAuthenticationManager.SignOut instead")]
[Obsolete("Use OWIN IAuthenticationManager.SignOut instead", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public static void UmbracoLogoutWebApi(this HttpResponseMessage response)
{
if (response == null) throw new ArgumentNullException("response");
//remove the cookie
var authCookie = new CookieHeaderValue(UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName, "")
{
Expires = DateTime.Now.AddYears(-1),
Path = "/"
};
//remove the preview cookie too
var prevCookie = new CookieHeaderValue(Constants.Web.PreviewCookieName, "")
{
Expires = DateTime.Now.AddYears(-1),
Path = "/"
};
//remove the external login cookie too
var extLoginCookie = new CookieHeaderValue(Constants.Security.BackOfficeExternalCookieName, "")
{
Expires = DateTime.Now.AddYears(-1),
Path = "/"
};
response.Headers.AddCookies(new[] { authCookie, prevCookie, extLoginCookie });
throw new NotSupportedException("This method is not supported and should not be used, it has been removed in Umbraco 7.4");
}
[Obsolete("Use WebSecurity.SetPrincipalForRequest")]
[Obsolete("Use WebSecurity.SetPrincipalForRequest", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public static FormsAuthenticationTicket UmbracoLoginWebApi(this HttpResponseMessage response, IUser user)
{
if (response == null) throw new ArgumentNullException("response");
//remove the external login cookie
var extLoginCookie = new CookieHeaderValue(Constants.Security.BackOfficeExternalCookieName, "")
{
Expires = DateTime.Now.AddYears(-1),
Path = "/"
};
var userDataString = JsonConvert.SerializeObject(Mapper.Map<UserData>(user));
var ticket = new FormsAuthenticationTicket(
4,
user.Username,
DateTime.Now,
DateTime.Now.AddMinutes(GlobalSettings.TimeOutInMinutes),
true,
userDataString,
"/"
);
// Encrypt the cookie using the machine key for secure transport
var encrypted = FormsAuthentication.Encrypt(ticket);
//add the cookie
var authCookie = new CookieHeaderValue(UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName, encrypted)
{
//Umbraco has always persisted it's original cookie for 1 day so we'll keep it that way
Expires = DateTime.Now.AddMinutes(1440),
Path = "/",
Secure = GlobalSettings.UseSSL,
HttpOnly = true
};
response.Headers.AddCookies(new[] { authCookie, extLoginCookie });
return ticket;
throw new NotSupportedException("This method is not supported and should not be used, it has been removed in Umbraco 7.4");
}
/// <summary>