V11/feature/update to dotnet 7 (#12712)

* 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>
This commit is contained in:
Nikolaj Geisle
2022-08-23 11:31:05 +02:00
committed by GitHub
parent 100ebf5c7f
commit 1b5225f4cd
90 changed files with 496 additions and 368 deletions

View File

@@ -90,7 +90,7 @@ public class BackOfficeUserManager : UmbracoUserManager<BackOfficeIdentityUser,
return result;
}
public override async Task<IdentityResult> ChangePasswordWithResetAsync(string userId, string token, string? newPassword)
public override async Task<IdentityResult> ChangePasswordWithResetAsync(string userId, string token, string newPassword)
{
IdentityResult result = await base.ChangePasswordWithResetAsync(userId, token, newPassword);
if (result.Succeeded)
@@ -101,7 +101,7 @@ public class BackOfficeUserManager : UmbracoUserManager<BackOfficeIdentityUser,
return result;
}
public override async Task<IdentityResult> ChangePasswordAsync(BackOfficeIdentityUser user, string? currentPassword, string? newPassword)
public override async Task<IdentityResult> ChangePasswordAsync(BackOfficeIdentityUser user, string currentPassword, string newPassword)
{
IdentityResult result = await base.ChangePasswordAsync(user, currentPassword, newPassword);
if (result.Succeeded)

View File

@@ -18,7 +18,7 @@ public sealed class ConfigureMemberCookieOptions : IConfigureNamedOptions<Cookie
_umbracoRequestPaths = umbracoRequestPaths;
}
public void Configure(string name, CookieAuthenticationOptions options)
public void Configure(string? name, CookieAuthenticationOptions options)
{
if (name == IdentityConstants.ApplicationScheme || name == IdentityConstants.ExternalScheme)
{

View File

@@ -21,11 +21,14 @@ public class ConfigureSecurityStampOptions : IConfigureOptions<SecurityStampVali
// to flow through to this new one.
options.OnRefreshingPrincipal = refreshingPrincipal =>
{
ClaimsIdentity newIdentity = refreshingPrincipal.NewPrincipal.Identities.First();
ClaimsIdentity currentIdentity = refreshingPrincipal.CurrentPrincipal.Identities.First();
ClaimsIdentity? newIdentity = refreshingPrincipal.NewPrincipal?.Identities.First();
ClaimsIdentity? currentIdentity = refreshingPrincipal.CurrentPrincipal?.Identities.First();
// Since this is refreshing an existing principal, we want to merge all claims.
newIdentity.MergeAllClaims(currentIdentity);
if (currentIdentity is not null)
{
// Since this is refreshing an existing principal, we want to merge all claims.
newIdentity?.MergeAllClaims(currentIdentity);
}
return Task.CompletedTask;
};

View File

@@ -19,7 +19,7 @@ public interface IBackOfficeSignInManager
Task<ExternalLoginInfo?> GetExternalLoginInfoAsync(string? expectedXsrf = null);
Task<BackOfficeIdentityUser> GetTwoFactorAuthenticationUserAsync();
Task<BackOfficeIdentityUser?> GetTwoFactorAuthenticationUserAsync();
Task<SignInResult> PasswordSignInAsync(string userName, string password, bool isPersistent, bool lockoutOnFailure);
@@ -29,7 +29,7 @@ public interface IBackOfficeSignInManager
Task<ClaimsPrincipal> CreateUserPrincipalAsync(BackOfficeIdentityUser user);
Task<SignInResult> TwoFactorSignInAsync(string? provider, string? code, bool isPersistent, bool rememberClient);
Task<SignInResult> TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberClient);
Task<IdentityResult> UpdateExternalAuthenticationTokensAsync(ExternalLoginInfo externalLogin);
}

View File

@@ -21,7 +21,7 @@ public interface IMemberSignInManager
Task<SignInResult> ExternalLoginSignInAsync(ExternalLoginInfo loginInfo, bool isPersistent, bool bypassTwoFactor = false);
Task<MemberIdentityUser> GetTwoFactorAuthenticationUserAsync();
Task<MemberIdentityUser?> GetTwoFactorAuthenticationUserAsync();
Task<SignInResult> TwoFactorSignInAsync(string? provider, string? code, bool isPersistent, bool rememberClient);
Task<SignInResult> TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberClient);
}

View File

@@ -188,7 +188,7 @@ public class MemberManager : UmbracoUserManager<MemberIdentityUser, MemberPasswo
return null;
}
_currentMember = await GetUserAsync(_httpContextAccessor.HttpContext?.User);
_currentMember = await GetUserAsync(_httpContextAccessor.HttpContext?.User!);
}
return _currentMember;
@@ -204,7 +204,7 @@ public class MemberManager : UmbracoUserManager<MemberIdentityUser, MemberPasswo
private async Task<bool> HasAccessAsync(string path)
{
MemberIdentityUser? currentMember = await GetCurrentMemberAsync();
if (currentMember == null || !currentMember.IsApproved || currentMember.IsLockedOut)
if (currentMember?.UserName is null || !currentMember.IsApproved || currentMember.IsLockedOut)
{
return false;
}
@@ -220,7 +220,7 @@ public class MemberManager : UmbracoUserManager<MemberIdentityUser, MemberPasswo
var result = new Dictionary<string, bool>();
MemberIdentityUser? currentMember = await GetCurrentMemberAsync();
if (currentMember == null || !currentMember.IsApproved || currentMember.IsLockedOut)
if (currentMember?.UserName is null || !currentMember.IsApproved || currentMember.IsLockedOut)
{
return result;
}

View File

@@ -159,8 +159,8 @@ public class MemberSignInManager : UmbracoSignInManager<MemberIdentityUser>, IMe
}
public override AuthenticationProperties ConfigureExternalAuthenticationProperties(
string provider,
string redirectUrl,
string? provider,
string? redirectUrl,
string? userId = null)
{
// borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs
@@ -213,7 +213,7 @@ public class MemberSignInManager : UmbracoSignInManager<MemberIdentityUser>, IMe
}
// Now we need to perform the auto-link, so first we need to lookup/create a user with the email address
MemberIdentityUser? autoLinkUser = await UserManager.FindByEmailAsync(email);
MemberIdentityUser? autoLinkUser = await UserManager.FindByEmailAsync(email!);
if (autoLinkUser != null)
{
try
@@ -244,7 +244,7 @@ public class MemberSignInManager : UmbracoSignInManager<MemberIdentityUser>, IMe
throw new InvalidOperationException("The Name value cannot be null");
}
autoLinkUser = MemberIdentityUser.CreateNew(email, email, autoLinkOptions.DefaultMemberTypeAlias, autoLinkOptions.DefaultIsApproved, name);
autoLinkUser = MemberIdentityUser.CreateNew(email!, email!, autoLinkOptions.DefaultMemberTypeAlias, autoLinkOptions.DefaultIsApproved, name);
foreach (var userGroup in autoLinkOptions.DefaultMemberGroups)
{

View File

@@ -47,7 +47,7 @@ public class PublicAccessChecker : IPublicAccessChecker
return PublicAccessStatus.LockedOut;
}
if (!_publicAccessService.HasAccess(publishedContentId, _contentService, username, userRoles))
if (!_publicAccessService.HasAccess(publishedContentId, _contentService, username!, userRoles))
{
return PublicAccessStatus.AccessDenied;
}

View File

@@ -86,7 +86,7 @@ public abstract class UmbracoSignInManager<TUser> : SignInManager<TUser>
var providerKey = auth.Principal.FindFirstValue(ClaimTypes.NameIdentifier);
var provider = items[UmbracoSignInMgrLoginProviderKey];
if (providerKey == null || provider == null)
if (providerKey is null || provider is null)
{
return null;
}
@@ -102,14 +102,14 @@ public abstract class UmbracoSignInManager<TUser> : SignInManager<TUser>
}
/// <inheritdoc />
public override async Task<TUser> GetTwoFactorAuthenticationUserAsync()
public override async Task<TUser?> GetTwoFactorAuthenticationUserAsync()
{
// borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs
// replaced in order to use a custom auth type
TwoFactorAuthenticationInfo? info = await RetrieveTwoFactorInfoAsync();
if (info == null)
if (info?.UserId is null)
{
return null!;
return null;
}
return await UserManager.FindByIdAsync(info.UserId);
@@ -142,7 +142,7 @@ public abstract class UmbracoSignInManager<TUser> : SignInManager<TUser>
}
/// <inheritdoc />
public override async Task<SignInResult> TwoFactorSignInAsync(string? provider, string? code, bool isPersistent, bool rememberClient)
public override async Task<SignInResult> TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberClient)
{
// borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs#L552
// replaced in order to use a custom auth type and to implement logging/events