From 184233af61978c0769714e804c15154551a07287 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 5 Dec 2014 10:40:46 -0800 Subject: [PATCH] #79: Remove cookie compression. --- .../CookieAuthenticationMiddleware.cs | 2 +- .../project.json | 1 - .../Serializer/TicketSerializer.cs | 30 +++---------------- src/Microsoft.AspNet.Security/project.json | 6 +--- 4 files changed, 6 insertions(+), 33 deletions(-) diff --git a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs index 482f43b37..8f1cc4b54 100644 --- a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs @@ -36,7 +36,7 @@ public CookieAuthenticationMiddleware(RequestDelegate next, if (Options.TicketDataFormat == null) { IDataProtector dataProtector = dataProtectionProvider.CreateDataProtector( - typeof(CookieAuthenticationMiddleware).FullName, Options.AuthenticationType, "v1"); + typeof(CookieAuthenticationMiddleware).FullName, Options.AuthenticationType, "v2"); Options.TicketDataFormat = new TicketDataFormat(dataProtector); } if (Options.CookieManager == null) diff --git a/src/Microsoft.AspNet.Security.OAuth/project.json b/src/Microsoft.AspNet.Security.OAuth/project.json index bae60ec0b..0c44ae0cf 100644 --- a/src/Microsoft.AspNet.Security.OAuth/project.json +++ b/src/Microsoft.AspNet.Security.OAuth/project.json @@ -26,7 +26,6 @@ "System.Dynamic.Runtime": "4.0.0-beta-*", "System.Globalization": "4.0.10-beta-*", "System.IO": "4.0.10-beta-*", - "System.IO.Compression": "4.0.0-beta-*", "System.Linq": "4.0.0-beta-*", "System.Net.Http.WinHttpHandler": "4.0.0-beta-*", "System.ObjectModel": "4.0.10-beta-*", diff --git a/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs b/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs index 7bfa9a1e6..9fe982ee8 100644 --- a/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs +++ b/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs @@ -1,11 +1,8 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - using System; -using System.Collections.Generic; using System.IO; -using System.IO.Compression; using System.Linq; using System.Security.Claims; @@ -13,46 +10,27 @@ namespace Microsoft.AspNet.Security.DataHandler.Serializer { public class TicketSerializer : IDataSerializer { - private static readonly bool IsMono = Type.GetType("Mono.Runtime") != null; private const int FormatVersion = 2; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")] public virtual byte[] Serialize(AuthenticationTicket model) { using (var memory = new MemoryStream()) { - GZipStream compression; - if (IsMono) - { - // The other constructor is not currently supported on Mono. - compression = new GZipStream(memory, CompressionMode.Compress); - } - else - { - compression = new GZipStream(memory, CompressionLevel.Optimal); - } - using (compression) + using (var writer = new BinaryWriter(memory)) { - using (var writer = new BinaryWriter(compression)) - { - Write(writer, model); - } + Write(writer, model); } return memory.ToArray(); } } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")] public virtual AuthenticationTicket Deserialize(byte[] data) { using (var memory = new MemoryStream(data)) { - using (var compression = new GZipStream(memory, CompressionMode.Decompress)) + using (var reader = new BinaryReader(memory)) { - using (var reader = new BinaryReader(compression)) - { - return Read(reader); - } + return Read(reader); } } } diff --git a/src/Microsoft.AspNet.Security/project.json b/src/Microsoft.AspNet.Security/project.json index 5ffa51a5c..cac89fbad 100644 --- a/src/Microsoft.AspNet.Security/project.json +++ b/src/Microsoft.AspNet.Security/project.json @@ -10,10 +10,6 @@ }, "frameworks": { "aspnet50": { }, - "aspnetcore50": { - "dependencies": { - "System.IO.Compression": "4.0.0-beta-*" - } - } + "aspnetcore50": { } } }