From ca95189a3baae38848b92dbec6fcfa948907eb6f Mon Sep 17 00:00:00 2001 From: Levi B Date: Mon, 20 Oct 2014 13:43:03 -0700 Subject: [PATCH] Allow DpapiNGXmlEncryptor to get the current identity's SID on CoreCLR. --- .../XmlEncryption/DpapiNGXmlEncryptor.cs | 9 +-------- .../project.json | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNet.Security.DataProtection/XmlEncryption/DpapiNGXmlEncryptor.cs b/src/Microsoft.AspNet.Security.DataProtection/XmlEncryption/DpapiNGXmlEncryptor.cs index bb123d73b3..b6930aa488 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/XmlEncryption/DpapiNGXmlEncryptor.cs +++ b/src/Microsoft.AspNet.Security.DataProtection/XmlEncryption/DpapiNGXmlEncryptor.cs @@ -4,15 +4,12 @@ using System; using System.Globalization; using System.IO; +using System.Security.Principal; using System.Xml.Linq; using Microsoft.AspNet.Security.DataProtection.Cng; using Microsoft.AspNet.Security.DataProtection.KeyManagement; using Microsoft.AspNet.Security.DataProtection.SafeHandles; -#if !ASPNETCORE50 -using System.Security.Principal; -#endif - namespace Microsoft.AspNet.Security.DataProtection.XmlEncryption { /// @@ -79,7 +76,6 @@ namespace Microsoft.AspNet.Security.DataProtection.XmlEncryption private static string GetDefaultProtectionDescriptorString() { -#if !ASPNETCORE50 // Creates a SID=... protection descriptor string for the current user. // Reminder: DPAPI:NG provides only encryption, not authentication. using (WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent()) @@ -87,9 +83,6 @@ namespace Microsoft.AspNet.Security.DataProtection.XmlEncryption // use the SID to create an SDDL string return String.Format(CultureInfo.InvariantCulture, "SID={0}", currentIdentity.User.Value); } -#else - throw new NotImplementedException("TODO: Doesn't yet work on Core CLR."); -#endif } } } diff --git a/src/Microsoft.AspNet.Security.DataProtection/project.json b/src/Microsoft.AspNet.Security.DataProtection/project.json index b7a1aad940..a6382d436f 100644 --- a/src/Microsoft.AspNet.Security.DataProtection/project.json +++ b/src/Microsoft.AspNet.Security.DataProtection/project.json @@ -44,6 +44,7 @@ "System.Security.Cryptography.Encryption.Aes": "4.0.0-beta-*", "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", "System.Security.Cryptography.RandomNumberGenerator": "4.0.0-beta-*", + "System.Security.Principal.Windows": "4.0.0-beta-*", "System.Text.Encoding.Extensions": "4.0.10-beta-*", "System.Threading": "4.0.0-beta-*", "System.Xml.XDocument": "4.0.0-beta-*"