* Update projects to .NET 7 * Fix nullability errors * Fix up pipelines to run 7.0 * Update langversion to preview * Revert "Fix up pipelines to run 7.0" This reverts commit d0fa8d01b8126a4eaa59832a3814a567705419ae. * Fix up pipelines again, this time without indentation changes * Include preview versions * Versions not Version * Fix ModelTypeTests * Fix MemberPasswordHasherTests Microsoft wants to use SHA512 instead of SHA256, so our old hashes will return SuccessRehashNeeded now * Use dotnet cli instead of nuget restore * Update src/Umbraco.Web.UI/Umbraco.Web.UI.csproj * Update dependencies * Fix nullability issues * Fix unit test * Fix nullability in ChangingPasswordModel OldPassword can be null, if we're changing the password with password reset enabled. Additionally, we might as well use the new required keyword instead of supressing null. * Use required keyword instead of supressing null * Fix up pipelines again * fix up spelling-error * Use dotnet cli instead of nuget restore * Fix up another NuGet command * Use dotnet version 7 before building * Include preview versions * Remove condition * Use dotnet 7 before running powershell script * Update templates to .net 7 * Download version 7 before running linux container * Move use dotnet 7 even earlier in E2E process * Remove dotnet 7 * Reintroduce .NET 7 task * Update linux docker container and remove dotnet 7 from yml * Fix up dockerfile with ARG * Fix up docker file with nightly builds of dotnet 7 * Reintroduce dotnet 7 so windows can use it * Use aspnet 7 in docker Co-authored-by: Nikolaj <nikolajlauridsen@protonmail.ch> Co-authored-by: Zeegaan <nge@umbraco.dk>
47 lines
1.9 KiB
C#
47 lines
1.9 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System.Security.Claims;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Security;
|
|
|
|
namespace Umbraco.Extensions;
|
|
|
|
public static class MergeClaimsIdentityExtensions
|
|
{
|
|
// Ignore these Claims when merging, these claims are dynamically added whenever the ticket
|
|
// is re-issued and we don't want to merge old values of these.
|
|
// We do however want to merge these when the SecurityStampValidator refreshes the principal since it's still the same login session
|
|
private static readonly string[] _ignoredClaims = { ClaimTypes.CookiePath, Constants.Security.SessionIdClaimType };
|
|
|
|
public static void MergeAllClaims(this ClaimsIdentity destination, ClaimsIdentity source)
|
|
{
|
|
foreach (Claim claim in source.Claims
|
|
.Where(claim => !destination.HasClaim(claim.Type, claim.Value)))
|
|
{
|
|
destination.AddClaim(new Claim(claim.Type, claim.Value));
|
|
}
|
|
}
|
|
|
|
public static void MergeClaimsFromCookieIdentity(this ClaimsIdentity destination, ClaimsIdentity source)
|
|
{
|
|
foreach (Claim claim in source.Claims
|
|
.Where(claim => !_ignoredClaims.Contains(claim.Type))
|
|
.Where(claim => !destination.HasClaim(claim.Type, claim.Value)))
|
|
{
|
|
destination.AddClaim(new Claim(claim.Type, claim.Value));
|
|
}
|
|
}
|
|
|
|
public static void MergeClaimsFromBackOfficeIdentity(this ClaimsIdentity destination, BackOfficeIdentityUser source)
|
|
{
|
|
foreach (IdentityUserClaim<string> claim in source.Claims
|
|
.Where(claim => !_ignoredClaims.Contains(claim.ClaimType))
|
|
.Where(claim => !destination.HasClaim(claim.ClaimType!, claim.ClaimValue!)))
|
|
{
|
|
destination.AddClaim(new Claim(claim.ClaimType!, claim.ClaimValue!));
|
|
}
|
|
}
|
|
}
|