Skip to content

Commit b845acd

Browse files
authored
Enable nullable on Authentication.MicrosoftAccount (#29253)
1 parent 8e95819 commit b845acd

File tree

7 files changed

+51
-50
lines changed

7 files changed

+51
-50
lines changed

src/Security/Authentication/MicrosoftAccount/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount.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>

src/Security/Authentication/MicrosoftAccount/src/MicrosoftAccountHandler.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(ClaimsIden
4848
var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
4949
context.RunClaimActions();
5050
await Events.CreatingTicket(context);
51-
return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name);
51+
return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name);
5252
}
5353
}
5454

@@ -89,17 +89,17 @@ protected override string BuildChallengeUrl(AuthenticationProperties properties,
8989
var state = Options.StateDataFormat.Protect(properties);
9090
queryStrings.Add("state", state);
9191

92-
return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, queryStrings);
92+
return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, queryStrings!);
9393
}
9494

9595
private void AddQueryString<T>(
96-
IDictionary<string, string> queryStrings,
96+
Dictionary<string, string> queryStrings,
9797
AuthenticationProperties properties,
9898
string name,
9999
Func<T, string> formatter,
100100
T defaultValue)
101101
{
102-
string value = null;
102+
string? value;
103103
var parameterValue = properties.GetParameter<T>(name);
104104
if (parameterValue != null)
105105
{
@@ -120,10 +120,10 @@ private void AddQueryString<T>(
120120
}
121121

122122
private void AddQueryString(
123-
IDictionary<string, string> queryStrings,
123+
Dictionary<string, string> queryStrings,
124124
AuthenticationProperties properties,
125125
string name,
126-
string defaultValue = null)
127-
=> AddQueryString(queryStrings, properties, name, x => x, defaultValue);
126+
string? defaultValue = null)
127+
=> AddQueryString(queryStrings, properties, name, x => x!, defaultValue);
128128
}
129129
}

src/Security/Authentication/MicrosoftAccount/src/MicrosoftChallengeProperties.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ public MicrosoftChallengeProperties()
4141
/// Initializes a new instance for <see cref="MicrosoftChallengeProperties"/>.
4242
/// </summary>
4343
/// <inheritdoc />
44-
public MicrosoftChallengeProperties(IDictionary<string, string> items)
44+
public MicrosoftChallengeProperties(IDictionary<string, string?> items)
4545
: base(items)
4646
{ }
4747

4848
/// <summary>
4949
/// Initializes a new instance for <see cref="MicrosoftChallengeProperties"/>.
5050
/// </summary>
5151
/// <inheritdoc />
52-
public MicrosoftChallengeProperties(IDictionary<string, string> items, IDictionary<string, object> parameters)
52+
public MicrosoftChallengeProperties(IDictionary<string, string?> items, IDictionary<string, object?> parameters)
5353
: base(items, parameters)
5454
{ }
5555

@@ -58,7 +58,7 @@ public MicrosoftChallengeProperties(IDictionary<string, string> items, IDictiona
5858
/// that should be used to send the resulting token back to the app. Can be one of the following: <c>query</c>, <c>fragment</c>, <c>form_post</c>.
5959
/// </summary>
6060
[Obsolete("This parameter is not supported in MicrosoftAccountHandler.")]
61-
public string ResponseMode
61+
public string? ResponseMode
6262
{
6363
get => GetParameter<string>(ResponseModeKey);
6464
set => SetParameter(ResponseModeKey, value);
@@ -71,7 +71,7 @@ public string ResponseMode
7171
/// leading to a slightly more streamlined user experience.
7272
/// </para>
7373
/// </summary>
74-
public string DomainHint
74+
public string? DomainHint
7575
{
7676
get => GetParameter<string>(DomainHintKey);
7777
set => SetParameter(DomainHintKey, value);
@@ -83,7 +83,7 @@ public string DomainHint
8383
/// Can be used to pre-fill the username/email address field of the sign-in page for the user, if their username is known ahead of time.
8484
/// </para>
8585
/// </summary>
86-
public string LoginHint
86+
public string? LoginHint
8787
{
8888
get => GetParameter<string>(LoginHintKey);
8989
set => SetParameter(LoginHintKey, value);
@@ -95,7 +95,7 @@ public string LoginHint
9595
/// Indicates the type of user interaction that is required. The only valid values at this time are login, none, and consent.
9696
/// </para>
9797
/// </summary>
98-
public string Prompt
98+
public string? Prompt
9999
{
100100
get => GetParameter<string>(PromptKey);
101101
set => SetParameter(PromptKey, value);

src/Security/Authentication/MicrosoftAccount/src/PublicAPI.Shipped.txt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions.Mic
66
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties
77
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.MicrosoftChallengeProperties() -> void
88
Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions
9-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler.MicrosoftAccountHandler(Microsoft.Extensions.Options.IOptionsMonitor<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions> options, Microsoft.Extensions.Logging.ILoggerFactory logger, System.Text.Encodings.Web.UrlEncoder encoder, Microsoft.AspNetCore.Authentication.ISystemClock clock) -> void
10-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.DomainHint.get -> string
11-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.DomainHint.set -> void
12-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.LoginHint.get -> string
13-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.LoginHint.set -> void
14-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.MicrosoftChallengeProperties(System.Collections.Generic.IDictionary<string, string> items) -> void
15-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.MicrosoftChallengeProperties(System.Collections.Generic.IDictionary<string, string> items, System.Collections.Generic.IDictionary<string, object> parameters) -> void
16-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.Prompt.get -> string
17-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.Prompt.set -> void
18-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.ResponseMode.get -> string
19-
~Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.ResponseMode.set -> void
20-
~const Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.AuthenticationScheme = "Microsoft" -> string
21-
~override Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler.BuildChallengeUrl(Microsoft.AspNetCore.Authentication.AuthenticationProperties properties, string redirectUri) -> string
22-
~override Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler.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>
23-
~static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
24-
~static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, System.Action<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions> configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
25-
~static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string authenticationScheme, System.Action<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions> configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
26-
~static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string authenticationScheme, string displayName, System.Action<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions> configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
27-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.AuthorizationEndpoint -> string
28-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.DisplayName -> string
29-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.TokenEndpoint -> string
30-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.UserInformationEndpoint -> string
31-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.DomainHintKey -> string
32-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.LoginHintKey -> string
33-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.PromptKey -> string
34-
~static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.ResponseModeKey -> string
9+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler.MicrosoftAccountHandler(Microsoft.Extensions.Options.IOptionsMonitor<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions!>! options, Microsoft.Extensions.Logging.ILoggerFactory! logger, System.Text.Encodings.Web.UrlEncoder! encoder, Microsoft.AspNetCore.Authentication.ISystemClock! clock) -> void
10+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.DomainHint.get -> string?
11+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.DomainHint.set -> void
12+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.LoginHint.get -> string?
13+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.LoginHint.set -> void
14+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.MicrosoftChallengeProperties(System.Collections.Generic.IDictionary<string!, string?>! items) -> void
15+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.MicrosoftChallengeProperties(System.Collections.Generic.IDictionary<string!, string?>! items, System.Collections.Generic.IDictionary<string!, object?>! parameters) -> void
16+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.Prompt.get -> string?
17+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.Prompt.set -> void
18+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.ResponseMode.get -> string?
19+
Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.ResponseMode.set -> void
20+
const Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.AuthenticationScheme = "Microsoft" -> string!
21+
override Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler.BuildChallengeUrl(Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties, string! redirectUri) -> string!
22+
override Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler.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!>!
23+
static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
24+
static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, System.Action<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
25+
static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! authenticationScheme, System.Action<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
26+
static Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions.AddMicrosoftAccount(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder! builder, string! authenticationScheme, string! displayName, System.Action<Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions!>! configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder!
27+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.AuthorizationEndpoint -> string!
28+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.DisplayName -> string!
29+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.TokenEndpoint -> string!
30+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults.UserInformationEndpoint -> string!
31+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.DomainHintKey -> string!
32+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.LoginHintKey -> string!
33+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.PromptKey -> string!
34+
static readonly Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftChallengeProperties.ResponseModeKey -> string!

src/Security/Authentication/OAuth/src/ClaimActionCollectionMapExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static void MapJsonSubKey(this ClaimActionCollection collection, string c
9292
/// <param name="collection">The <see cref="ClaimActionCollection"/>.</param>
9393
/// <param name="claimType">The value to use for Claim.Type when creating a Claim.</param>
9494
/// <param name="resolver">The Func that will be called to select value from the given json user data.</param>
95-
public static void MapCustomJson(this ClaimActionCollection collection, string claimType, Func<JsonElement, string> resolver)
95+
public static void MapCustomJson(this ClaimActionCollection collection, string claimType, Func<JsonElement, string?> resolver)
9696
{
9797
if (collection == null)
9898
{
@@ -110,7 +110,7 @@ public static void MapCustomJson(this ClaimActionCollection collection, string c
110110
/// <param name="claimType">The value to use for Claim.Type when creating a Claim.</param>
111111
/// <param name="valueType">The value to use for Claim.ValueType when creating a Claim.</param>
112112
/// <param name="resolver">The Func that will be called to select value from the given json user data.</param>
113-
public static void MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func<JsonElement, string> resolver)
113+
public static void MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func<JsonElement, string?> resolver)
114114
{
115115
if (collection == null)
116116
{

src/Security/Authentication/OAuth/src/CustomJsonClaimAction.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Microsoft.AspNetCore.Authentication.OAuth.Claims
99
{
1010
/// <summary>
11-
/// A ClaimAction that selects the value from the json user data by running the given Func resolver.
11+
/// A ClaimAction that selects the value from the JSON user data by running the given Func resolver.
1212
/// </summary>
1313
public class CustomJsonClaimAction : ClaimAction
1414
{
@@ -17,17 +17,17 @@ public class CustomJsonClaimAction : ClaimAction
1717
/// </summary>
1818
/// <param name="claimType">The value to use for Claim.Type when creating a Claim.</param>
1919
/// <param name="valueType">The value to use for Claim.ValueType when creating a Claim.</param>
20-
/// <param name="resolver">The Func that will be called to select value from the given json user data.</param>
21-
public CustomJsonClaimAction(string claimType, string valueType, Func<JsonElement, string> resolver)
20+
/// <param name="resolver">The Func that will be called to select value from the given JSON user data.</param>
21+
public CustomJsonClaimAction(string claimType, string valueType, Func<JsonElement, string?> resolver)
2222
: base(claimType, valueType)
2323
{
2424
Resolver = resolver;
2525
}
2626

2727
/// <summary>
28-
/// The Func that will be called to select value from the given json user data.
28+
/// The Func that will be called to select value from the given JSON user data.
2929
/// </summary>
30-
public Func<JsonElement, string> Resolver { get; }
30+
public Func<JsonElement, string?> Resolver { get; }
3131

3232
/// <inheritdoc />
3333
public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer)

0 commit comments

Comments
 (0)