Remove clone
It's no longer needed
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Security
|
||||
{
|
||||
// TODO: Ideally we remove this class and only deal with ClaimsIdentity as a best practice. All things relevant to our own
|
||||
// identity are part of claims. This class would essentially become extension methods on a ClaimsIdentity for resolving
|
||||
// values from it.
|
||||
// values from it.
|
||||
public static bool FromClaimsIdentity(ClaimsIdentity identity, out UmbracoBackOfficeIdentity backOfficeIdentity)
|
||||
{
|
||||
// validate that all claims exist
|
||||
@@ -214,19 +214,5 @@ namespace Umbraco.Core.Security
|
||||
public string SecurityStamp => this.FindFirstValue(Constants.Security.SecurityStampClaimType);
|
||||
|
||||
public string[] Roles => FindAll(x => x.Type == DefaultRoleClaimType).Select(role => role.Value).ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to remove any temporary claims that shouldn't be copied
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override ClaimsIdentity Clone()
|
||||
{
|
||||
var clone = base.Clone();
|
||||
|
||||
foreach (var claim in clone.FindAll(x => x.Type == Constants.Security.TicketExpiresClaimType).ToList())
|
||||
clone.RemoveClaim(claim);
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,22 +126,5 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.BackOffice
|
||||
Assert.AreEqual(12, identity.Claims.Count());
|
||||
Assert.IsNull(identity.Actor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Clone()
|
||||
{
|
||||
var securityStamp = Guid.NewGuid().ToString();
|
||||
|
||||
var identity = new UmbracoBackOfficeIdentity(
|
||||
"1234", "testing", "hello world", new[] { 654 }, new[] { 654 }, "en-us", securityStamp, new[] { "content", "media" }, new[] { "admin" });
|
||||
|
||||
// this will be filtered out during cloning
|
||||
identity.AddClaim(new Claim(Constants.Security.TicketExpiresClaimType, "test"));
|
||||
|
||||
ClaimsIdentity cloned = identity.Clone();
|
||||
Assert.IsNull(cloned.Actor);
|
||||
|
||||
Assert.AreEqual(10, cloned.Claims.Count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user