Skip to content

Commit 0afd56d

Browse files
committed
Add version in FormsAuthenticationCookie
1 parent 856df06 commit 0afd56d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Synercoding.FormsAuthentication/FormsAuthenticationCookie.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace Synercoding.FormsAuthentication
44
{
55
public class FormsAuthenticationCookie
66
{
7+
public byte Version { get; set; }
78
public DateTime IssuedUtc { get; set; }
89
public DateTime ExpiresUtc { get; set; }
910
public bool IsPersistent { get; set; }

src/Synercoding.FormsAuthentication/FormsAuthenticationCryptor.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private byte[] ConvertToBytes(FormsAuthenticationCookie data)
5656
using (var ticketWriter = new SerializingBinaryWriter(ticketBlobStream))
5757
{
5858
ticketWriter.Write((byte)1);
59-
ticketWriter.Write((byte)1);
59+
ticketWriter.Write(data.Version);
6060
ticketWriter.Write(data.IssuedUtc.Ticks);
6161
ticketWriter.Write((byte)0xfe);
6262
ticketWriter.Write(data.ExpiresUtc.Ticks);
@@ -82,7 +82,7 @@ private FormsAuthenticationCookie ConvertToAuthenticationTicket(byte[] data)
8282
if (serializedFormatVersion != 0x01)
8383
throw new ArgumentException("The data is not in the correct format, first byte must be 0x01.", nameof(data));
8484

85-
int ticketVersion = ticketReader.ReadByte();
85+
byte ticketVersion = ticketReader.ReadByte();
8686

8787
DateTime ticketIssueDateUtc = new DateTime(ticketReader.ReadInt64(), DateTimeKind.Utc);
8888

@@ -103,7 +103,8 @@ private FormsAuthenticationCookie ConvertToAuthenticationTicket(byte[] data)
103103
//create ticket
104104
return new FormsAuthenticationCookie()
105105
{
106-
UserName = ticketName,
106+
Version = ticketVersion,
107+
UserName = ticketName,
107108
UserData = ticketUserData,
108109
CookiePath = ticketCookiePath,
109110
IsPersistent = ticketIsPersistent,

0 commit comments

Comments
 (0)