Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Remove cookie compression. #104

Merged
merged 1 commit into from
Dec 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.AspNet.Security.OAuth/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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-*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,36 @@
// 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;

namespace Microsoft.AspNet.Security.DataHandler.Serializer
{
public class TicketSerializer : IDataSerializer<AuthenticationTicket>
{
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);
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/Microsoft.AspNet.Security/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
},
"frameworks": {
"aspnet50": { },
"aspnetcore50": {
"dependencies": {
"System.IO.Compression": "4.0.0-beta-*"
}
}
"aspnetcore50": { }
}
}