Skip to content

Commit 84c0baa

Browse files
authored
Add nullability to Identity / Identity.UI (#40167)
Contributes to #5680
1 parent d75c220 commit 84c0baa

File tree

74 files changed

+1425
-319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1425
-319
lines changed

src/Identity/Core/src/DataProtectorTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public virtual async Task<string> GenerateAsync(string purpose, UserManager<TUse
8989
writer.Write(DateTimeOffset.UtcNow);
9090
writer.Write(userId);
9191
writer.Write(purpose ?? "");
92-
string stamp = null;
92+
string? stamp = null;
9393
if (manager.SupportsUserSecurityStamp)
9494
{
9595
stamp = await manager.GetSecurityStampAsync(user);

src/Identity/Core/src/ExternalLoginInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public ExternalLoginInfo(ClaimsPrincipal principal, string loginProvider, string
3333
/// <summary>
3434
/// The <see cref="AuthenticationToken"/>s associated with this login.
3535
/// </summary>
36-
public IEnumerable<AuthenticationToken> AuthenticationTokens { get; set; }
36+
public IEnumerable<AuthenticationToken>? AuthenticationTokens { get; set; }
3737

3838
/// <summary>
3939
/// The <see cref="Authentication.AuthenticationProperties"/> associated with this login.
4040
/// </summary>
41-
public AuthenticationProperties AuthenticationProperties { get; set; }
41+
public AuthenticationProperties? AuthenticationProperties { get; set; }
4242
}

src/Identity/Core/src/IdentityCookiesBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ public class IdentityCookiesBuilder
1414
/// <summary>
1515
/// Used to configure the application cookie.
1616
/// </summary>
17-
public OptionsBuilder<CookieAuthenticationOptions> ApplicationCookie { get; set; }
17+
public OptionsBuilder<CookieAuthenticationOptions>? ApplicationCookie { get; set; }
1818

1919
/// <summary>
2020
/// Used to configure the external cookie.
2121
/// </summary>
22-
public OptionsBuilder<CookieAuthenticationOptions> ExternalCookie { get; set; }
22+
public OptionsBuilder<CookieAuthenticationOptions>? ExternalCookie { get; set; }
2323

2424
/// <summary>
2525
/// Used to configure the two factor remember me cookie.
2626
/// </summary>
27-
public OptionsBuilder<CookieAuthenticationOptions> TwoFactorRememberMeCookie { get; set; }
27+
public OptionsBuilder<CookieAuthenticationOptions>? TwoFactorRememberMeCookie { get; set; }
2828

2929
/// <summary>
3030
/// Used to configure the two factor user id cookie.
3131
/// </summary>
32-
public OptionsBuilder<CookieAuthenticationOptions> TwoFactorUserIdCookie { get; set; }
32+
public OptionsBuilder<CookieAuthenticationOptions>? TwoFactorUserIdCookie { get; set; }
3333
}

src/Identity/Core/src/IdentityServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static IdentityBuilder AddIdentity<TUser, TRole>(
2424
this IServiceCollection services)
2525
where TUser : class
2626
where TRole : class
27-
=> services.AddIdentity<TUser, TRole>(setupAction: null);
27+
=> services.AddIdentity<TUser, TRole>(setupAction: null!);
2828

2929
/// <summary>
3030
/// Adds and configures the identity system for the specified User and Role types.

src/Identity/Core/src/LoggingExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#nullable disable
5+
46
namespace Microsoft.Extensions.Logging;
57

68
internal static class LoggingExtensions

src/Identity/Core/src/Microsoft.AspNetCore.Identity.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;identity;membership</PackageTags>
99
<IsPackable>false</IsPackable>
10-
<Nullable>disable</Nullable>
1110
</PropertyGroup>
1211

1312
<ItemGroup>

src/Identity/Core/src/PublicAPI.Unshipped.txt

Lines changed: 219 additions & 0 deletions
Large diffs are not rendered by default.

src/Identity/Core/src/SecurityStampRefreshingPrincipalContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public class SecurityStampRefreshingPrincipalContext
1313
/// <summary>
1414
/// The principal contained in the current cookie.
1515
/// </summary>
16-
public ClaimsPrincipal CurrentPrincipal { get; set; }
16+
public ClaimsPrincipal? CurrentPrincipal { get; set; }
1717

1818
/// <summary>
1919
/// The new principal which should replace the current.
2020
/// </summary>
21-
public ClaimsPrincipal NewPrincipal { get; set; }
21+
public ClaimsPrincipal? NewPrincipal { get; set; }
2222
}

src/Identity/Core/src/SecurityStampValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public SecurityStampValidator(IOptions<SecurityStampValidatorOptions> options, S
3636
SignInManager = signInManager;
3737
Options = options.Value;
3838
Clock = clock;
39-
Logger = logger.CreateLogger(this.GetType().FullName);
39+
Logger = logger.CreateLogger(GetType());
4040
}
4141

4242
/// <summary>
@@ -102,7 +102,7 @@ protected virtual async Task SecurityStampVerified(TUser user, CookieValidatePri
102102
/// </summary>
103103
/// <param name="principal">The principal to verify.</param>
104104
/// <returns>The verified user or null if verification fails.</returns>
105-
protected virtual Task<TUser> VerifySecurityStamp(ClaimsPrincipal principal)
105+
protected virtual Task<TUser?> VerifySecurityStamp(ClaimsPrincipal? principal)
106106
=> SignInManager.ValidateSecurityStampAsync(principal);
107107

108108
/// <summary>

src/Identity/Core/src/SecurityStampValidatorOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ public class SecurityStampValidatorOptions
1919
/// <summary>
2020
/// Invoked when the default security stamp validator replaces the user's ClaimsPrincipal in the cookie.
2121
/// </summary>
22-
public Func<SecurityStampRefreshingPrincipalContext, Task> OnRefreshingPrincipal { get; set; }
22+
public Func<SecurityStampRefreshingPrincipalContext, Task>? OnRefreshingPrincipal { get; set; }
2323
}

0 commit comments

Comments
 (0)