Skip to content

Commit 206ed86

Browse files
authored
Enable nullable on more authentication projects (#31230)
1 parent 70e7c40 commit 206ed86

File tree

52 files changed

+588
-233
lines changed

Some content is hidden

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

52 files changed

+588
-233
lines changed

src/Security/Authentication/Core/src/Events/RemoteAuthenticationContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected RemoteAuthenticationContext(
3535
/// <summary>
3636
/// Gets or sets the <see cref="AuthenticationProperties"/>.
3737
/// </summary>
38-
public virtual AuthenticationProperties Properties { get; set; }
38+
public virtual AuthenticationProperties? Properties { get; set; }
3939

4040
/// <summary>
4141
/// Calls success creating a ticket with the <see cref="Principal"/> and <see cref="Properties"/>.

src/Security/Authentication/Core/src/HandleRequestResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class HandleRequestResult : AuthenticateResult
5252
/// <param name="failure">The failure exception.</param>
5353
/// <param name="properties">Additional state values for the authentication session.</param>
5454
/// <returns>The result.</returns>
55-
public static new HandleRequestResult Fail(Exception failure, AuthenticationProperties properties)
55+
public static new HandleRequestResult Fail(Exception failure, AuthenticationProperties? properties)
5656
{
5757
return new HandleRequestResult() { Failure = failure, Properties = properties };
5858
}
@@ -71,7 +71,7 @@ public class HandleRequestResult : AuthenticateResult
7171
/// <param name="failureMessage">The failure message.</param>
7272
/// <param name="properties">Additional state values for the authentication session.</param>
7373
/// <returns>The result.</returns>
74-
public static new HandleRequestResult Fail(string failureMessage, AuthenticationProperties properties)
74+
public static new HandleRequestResult Fail(string failureMessage, AuthenticationProperties? properties)
7575
=> Fail(new Exception(failureMessage), properties);
7676

7777
/// <summary>

src/Security/Authentication/Core/src/IDataSerializer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public interface IDataSerializer<TModel>
2323
/// </summary>
2424
/// <param name="data">The bytes being deserialized.</param>
2525
/// <returns>The model.</returns>
26-
[return: MaybeNull]
27-
TModel Deserialize(byte[] data);
26+
TModel? Deserialize(byte[] data);
2827
}
2928
}

src/Security/Authentication/Core/src/ISecureDataFormat.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ public interface ISecureDataFormat<TData>
3131
/// </summary>
3232
/// <param name="protectedText">The data protected value.</param>
3333
/// <returns>An instance of <typeparamref name="TData"/>.</returns>
34-
[return: MaybeNull]
35-
TData Unprotect(string protectedText);
34+
TData? Unprotect(string? protectedText);
3635

3736
/// <summary>
3837
/// Unprotects the specified <paramref name="protectedText"/> using the specified <paramref name="purpose"/>.
3938
/// </summary>
4039
/// <param name="protectedText">The data protected value.</param>
4140
/// <param name="purpose">The purpose.</param>
4241
/// <returns>An instance of <typeparamref name="TData"/>.</returns>
43-
[return: MaybeNull]
44-
TData Unprotect(string protectedText, string? purpose);
42+
TData? Unprotect(string? protectedText, string? purpose);
4543
}
4644
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
#nullable enable
22
*REMOVED*Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions.ForwardDefaultSelector.get -> System.Func<Microsoft.AspNetCore.Http.HttpContext!, string!>?
33
Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions.ForwardDefaultSelector.get -> System.Func<Microsoft.AspNetCore.Http.HttpContext!, string?>?
4+
Microsoft.AspNetCore.Authentication.IDataSerializer<TModel>.Deserialize(byte[]! data) -> TModel?
5+
Microsoft.AspNetCore.Authentication.ISecureDataFormat<TData>.Unprotect(string? protectedText) -> TData?
6+
Microsoft.AspNetCore.Authentication.ISecureDataFormat<TData>.Unprotect(string? protectedText, string? purpose) -> TData?
7+
Microsoft.AspNetCore.Authentication.SecureDataFormat<TData>.Unprotect(string? protectedText) -> TData?
8+
Microsoft.AspNetCore.Authentication.SecureDataFormat<TData>.Unprotect(string? protectedText, string? purpose) -> TData?
9+
static Microsoft.AspNetCore.Authentication.HandleRequestResult.Fail(System.Exception! failure, Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties) -> Microsoft.AspNetCore.Authentication.HandleRequestResult!
10+
static Microsoft.AspNetCore.Authentication.HandleRequestResult.Fail(string! failureMessage, Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties) -> Microsoft.AspNetCore.Authentication.HandleRequestResult!
11+
virtual Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext<TOptions>.Properties.get -> Microsoft.AspNetCore.Authentication.AuthenticationProperties?
12+
*REMOVED*Microsoft.AspNetCore.Authentication.IDataSerializer<TModel>.Deserialize(byte[]! data) -> TModel
13+
*REMOVED*Microsoft.AspNetCore.Authentication.ISecureDataFormat<TData>.Unprotect(string! protectedText) -> TData
14+
*REMOVED*Microsoft.AspNetCore.Authentication.ISecureDataFormat<TData>.Unprotect(string! protectedText, string? purpose) -> TData
15+
*REMOVED*Microsoft.AspNetCore.Authentication.SecureDataFormat<TData>.Unprotect(string! protectedText) -> TData
16+
*REMOVED*Microsoft.AspNetCore.Authentication.SecureDataFormat<TData>.Unprotect(string! protectedText, string? purpose) -> TData
17+
*REMOVED*static Microsoft.AspNetCore.Authentication.HandleRequestResult.Fail(System.Exception! failure, Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties) -> Microsoft.AspNetCore.Authentication.HandleRequestResult!
18+
*REMOVED*static Microsoft.AspNetCore.Authentication.HandleRequestResult.Fail(string! failureMessage, Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties) -> Microsoft.AspNetCore.Authentication.HandleRequestResult!
19+
*REMOVED*virtual Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext<TOptions>.Properties.get -> Microsoft.AspNetCore.Authentication.AuthenticationProperties!

src/Security/Authentication/Core/src/RemoteAuthenticationHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public virtual async Task<bool> HandleRequestAsync()
145145
ticket.Properties.RedirectUri = null;
146146

147147
// Mark which provider produced this identity so we can cross-check later in HandleAuthenticateAsync
148-
ticketContext.Properties.Items[AuthSchemeKey] = Scheme.Name;
148+
ticketContext.Properties!.Items[AuthSchemeKey] = Scheme.Name;
149149

150150
await Events.TicketReceived(ticketContext);
151151

src/Security/Authentication/Core/src/SecureDataFormat.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,13 @@ public string Protect(TData data, string? purpose)
4848
}
4949

5050
/// <inheritdoc />
51-
[return: MaybeNull]
52-
public TData Unprotect(string protectedText)
51+
public TData? Unprotect(string? protectedText)
5352
{
5453
return Unprotect(protectedText, purpose: null);
5554
}
5655

5756
/// <inheritdoc />
58-
[return: MaybeNull]
59-
public TData Unprotect(string protectedText, string? purpose)
57+
public TData? Unprotect(string? protectedText, string? purpose)
6058
{
6159
try
6260
{

src/Security/Authentication/Facebook/src/FacebookHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public FacebookHandler(IOptionsMonitor<FacebookOptions> options, ILoggerFactory
3333
/// <inheritdoc />
3434
protected override async Task<AuthenticationTicket> CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens)
3535
{
36-
var endpoint = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, "access_token", tokens.AccessToken);
36+
var endpoint = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, "access_token", tokens.AccessToken!);
3737
if (Options.SendAppSecretProof)
3838
{
39-
endpoint = QueryHelpers.AddQueryString(endpoint, "appsecret_proof", GenerateAppSecretProof(tokens.AccessToken));
39+
endpoint = QueryHelpers.AddQueryString(endpoint, "appsecret_proof", GenerateAppSecretProof(tokens.AccessToken!));
4040
}
4141
if (Options.Fields.Count > 0)
4242
{
@@ -54,7 +54,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(ClaimsIden
5454
var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
5555
context.RunClaimActions();
5656
await Events.CreatingTicket(context);
57-
return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name);
57+
return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name);
5858
}
5959
}
6060

src/Security/Authentication/Facebook/src/Microsoft.AspNetCore.Authentication.Facebook.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<PackageTags>aspnetcore;authentication;security</PackageTags>
8+
<Nullable>enable</Nullable>
89
</PropertyGroup>
910

1011
<ItemGroup>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11
#nullable enable
2+
Microsoft.AspNetCore.Authentication.Facebook.FacebookHandler.FacebookHandler(Microsoft.Extensions.Options.IOptionsMonitor<Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions!>! options, Microsoft.Extensions.Logging.ILoggerFactory! logger, System.Text.Encodings.Web.UrlEncoder! encoder, Microsoft.AspNetCore.Authentication.ISystemClock! clock) -> void
3+
Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions.AppId.get -> string!
4+
Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions.AppId.set -> void
5+
Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions.AppSecret.get -> string!
6+
Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions.AppSecret.set -> void
7+
Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions.Fields.get -> System.Collections.Generic.ICollection<string!>!
8+
const Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults.AuthenticationScheme = "Facebook" -> string!
9+
override Microsoft.AspNetCore.Authentication.Facebook.FacebookHandler.CreateTicketAsync(System.Security.Claims.ClaimsIdentity! identity, Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties, Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse! tokens) -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Authentication.AuthenticationTicket!>!
10+
override Microsoft.AspNetCore.Authentication.Facebook.FacebookHandler.FormatScope() -> string!
11+
override Microsoft.AspNetCore.Authentication.Facebook.FacebookHandler.FormatScope(System.Collections.Generic.IEnumerable<string!>! scopes) -> string!
12+
static Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions.AddFacebook(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
13+
static Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions.AddFacebook(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, System.Action<Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
14+
static Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions.AddFacebook(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! authenticationScheme, System.Action<Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
15+
static Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions.AddFacebook(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! authenticationScheme, string! displayName, System.Action<Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
16+
static readonly Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults.AuthorizationEndpoint -> string!
17+
static readonly Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults.DisplayName -> string!
18+
static readonly Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults.TokenEndpoint -> string!
19+
static readonly Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults.UserInformationEndpoint -> string!

0 commit comments

Comments
 (0)