From 51a2924f783db601a4753402500888101650b01d Mon Sep 17 00:00:00 2001 From: martincostello Date: Wed, 15 Jul 2020 19:22:00 +0100 Subject: [PATCH 1/6] Update to ASP.NET 5 Updates to support ASP.NET 5, using preview 6. Remove obsolete members. --- Directory.Packages.props | 12 ++++++------ eng/Versions.props | 6 +++--- global.json | 2 +- samples/Mvc.Client/Mvc.Client.csproj | 2 +- .../AspNet.Security.OAuth.Amazon.csproj | 2 +- .../AppleAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Apple.csproj | 2 +- .../AspNet.Security.OAuth.ArcGIS.csproj | 2 +- .../AspNet.Security.OAuth.Asana.csproj | 2 +- .../AspNet.Security.OAuth.Autodesk.csproj | 2 +- .../AspNet.Security.OAuth.Automatic.csproj | 2 +- .../AspNet.Security.OAuth.Baidu.csproj | 2 +- .../AspNet.Security.OAuth.Basecamp.csproj | 2 +- .../AspNet.Security.OAuth.BattleNet.csproj | 2 +- .../AspNet.Security.OAuth.Beam.csproj | 2 +- .../AspNet.Security.OAuth.Bitbucket.csproj | 2 +- .../BitbucketAuthenticationHandler.cs | 6 +++--- .../AspNet.Security.OAuth.Buffer.csproj | 2 +- .../AspNet.Security.OAuth.CiscoSpark.csproj | 2 +- .../AspNet.Security.OAuth.Deezer.csproj | 2 +- .../DeezerAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.DeviantArt.csproj | 2 +- .../AspNet.Security.OAuth.Discord.csproj | 2 +- .../AspNet.Security.OAuth.Dropbox.csproj | 2 +- .../AspNet.Security.OAuth.EVEOnline.csproj | 2 +- .../AspNet.Security.OAuth.ExactOnline.csproj | 2 +- .../AspNet.Security.OAuth.Fitbit.csproj | 2 +- .../FitbitAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Foursquare.csproj | 2 +- .../AspNet.Security.OAuth.GitHub.csproj | 2 +- .../GitHubAuthenticationHandler.cs | 4 ++-- .../AspNet.Security.OAuth.GitLab.csproj | 2 +- .../AspNet.Security.OAuth.Gitee.csproj | 2 +- .../GiteeAuthenticationHandler.cs | 8 ++++---- .../AspNet.Security.OAuth.Gitter.csproj | 2 +- .../AspNet.Security.OAuth.Harvest.csproj | 2 +- .../AspNet.Security.OAuth.HealthGraph.csproj | 2 +- .../AspNet.Security.OAuth.Imgur.csproj | 2 +- .../AspNet.Security.OAuth.Instagram.csproj | 2 +- .../InstagramAuthenticationHandler.cs | 6 ------ .../InstagramAuthenticationOptions.cs | 10 ---------- .../AspNet.Security.OAuth.LinkedIn.csproj | 2 +- .../LinkedInAuthenticationOptions.cs | 6 +++--- .../AspNet.Security.OAuth.MailChimp.csproj | 2 +- .../AspNet.Security.OAuth.MailRu.csproj | 2 +- .../AspNet.Security.OAuth.Myob.csproj | 2 +- .../AspNet.Security.OAuth.NetEase.csproj | 2 +- .../AspNet.Security.OAuth.Nextcloud.csproj | 2 +- .../AspNet.Security.OAuth.Odnoklassniki.csproj | 2 +- .../OdnoklassnikiAuthenticationHandler.cs | 4 ++-- .../AspNet.Security.OAuth.Okta.csproj | 2 +- .../AspNet.Security.OAuth.Onshape.csproj | 2 +- .../AspNet.Security.OAuth.Patreon.csproj | 2 +- .../AspNet.Security.OAuth.Paypal.csproj | 2 +- .../AspNet.Security.OAuth.QQ.csproj | 2 +- .../AspNet.Security.OAuth.Reddit.csproj | 2 +- .../RedditAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Salesforce.csproj | 2 +- .../AspNet.Security.OAuth.Shopify.csproj | 2 +- .../ShopifyAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Slack.csproj | 2 +- .../AspNet.Security.OAuth.SoundCloud.csproj | 2 +- .../AspNet.Security.OAuth.Spotify.csproj | 2 +- .../AspNet.Security.OAuth.StackExchange.csproj | 2 +- .../StackExchangeAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Strava.csproj | 2 +- .../AspNet.Security.OAuth.SuperOffice.csproj | 2 +- .../SuperOfficeFunctionalRightsClaimAction.cs | 2 +- .../AspNet.Security.OAuth.Trakt.csproj | 2 +- .../AspNet.Security.OAuth.Twitch.csproj | 2 +- .../AspNet.Security.OAuth.Untappd.csproj | 2 +- .../AspNet.Security.OAuth.Vimeo.csproj | 2 +- .../AspNet.Security.OAuth.VisualStudio.csproj | 2 +- .../VisualStudioAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Vkontakte.csproj | 2 +- .../AspNet.Security.OAuth.Weibo.csproj | 2 +- .../WeiboAuthenticationHandler.cs | 6 +++--- .../AspNet.Security.OAuth.Weixin.csproj | 2 +- .../AspNet.Security.OAuth.WordPress.csproj | 2 +- .../AspNet.Security.OAuth.Yahoo.csproj | 2 +- .../YahooAuthenticationConstants.cs | 4 ---- .../YahooAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Yammer.csproj | 2 +- .../YammerAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Yandex.csproj | 2 +- .../YandexAuthenticationHandler.cs | 2 +- .../AspNet.Security.OAuth.Zalo.csproj | 2 +- .../AspNet.Security.OAuth.Providers.Tests.csproj | 2 +- .../Infrastructure/ApplicationFactory.cs | 2 +- .../Infrastructure/LoopbackRedirectHandler.cs | 12 ++++++------ .../OAuthTests`1.cs | 3 ++- 91 files changed, 112 insertions(+), 131 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 44ea9ebc6..273577462 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,16 +4,16 @@ - - - - + + + + - + - + diff --git a/eng/Versions.props b/eng/Versions.props index 66644c088..bf9b601b2 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,9 +1,9 @@ - 3 - 1 - 4 + 5 + 0 + 0 $(MajorVersion).$(MinorVersion).$(PatchVersion) preview false diff --git a/global.json b/global.json index 9ce57d61f..0a29fa16f 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "3.1.401" + "dotnet": "5.0.100-preview.6.20318.15" }, "msbuild-sdks": { diff --git a/samples/Mvc.Client/Mvc.Client.csproj b/samples/Mvc.Client/Mvc.Client.csproj index 26ae069d0..5a4e500e8 100644 --- a/samples/Mvc.Client/Mvc.Client.csproj +++ b/samples/Mvc.Client/Mvc.Client.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 AspNet.Security.OAuth.Providers.Mvc.Client diff --git a/src/AspNet.Security.OAuth.Amazon/AspNet.Security.OAuth.Amazon.csproj b/src/AspNet.Security.OAuth.Amazon/AspNet.Security.OAuth.Amazon.csproj index cba167850..0da04e1c0 100644 --- a/src/AspNet.Security.OAuth.Amazon/AspNet.Security.OAuth.Amazon.csproj +++ b/src/AspNet.Security.OAuth.Amazon/AspNet.Security.OAuth.Amazon.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs index ef61e37d8..f3232b820 100644 --- a/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs @@ -176,7 +176,7 @@ protected virtual IEnumerable ExtractClaimsFromUser([NotNull] JsonElement if (user.TryGetProperty("email", out var email)) { - claims.Add(new Claim(ClaimTypes.Email, email.GetString(), ClaimValueTypes.String, ClaimsIssuer)); + claims.Add(new Claim(ClaimTypes.Email, email.GetString() ?? string.Empty, ClaimValueTypes.String, ClaimsIssuer)); } return claims; diff --git a/src/AspNet.Security.OAuth.Apple/AspNet.Security.OAuth.Apple.csproj b/src/AspNet.Security.OAuth.Apple/AspNet.Security.OAuth.Apple.csproj index 73a3131cf..7e8d0e2eb 100644 --- a/src/AspNet.Security.OAuth.Apple/AspNet.Security.OAuth.Apple.csproj +++ b/src/AspNet.Security.OAuth.Apple/AspNet.Security.OAuth.Apple.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.ArcGIS/AspNet.Security.OAuth.ArcGIS.csproj b/src/AspNet.Security.OAuth.ArcGIS/AspNet.Security.OAuth.ArcGIS.csproj index c7abb68f7..e45119ecc 100644 --- a/src/AspNet.Security.OAuth.ArcGIS/AspNet.Security.OAuth.ArcGIS.csproj +++ b/src/AspNet.Security.OAuth.ArcGIS/AspNet.Security.OAuth.ArcGIS.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Asana/AspNet.Security.OAuth.Asana.csproj b/src/AspNet.Security.OAuth.Asana/AspNet.Security.OAuth.Asana.csproj index a61033ad5..442e298a9 100644 --- a/src/AspNet.Security.OAuth.Asana/AspNet.Security.OAuth.Asana.csproj +++ b/src/AspNet.Security.OAuth.Asana/AspNet.Security.OAuth.Asana.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Autodesk/AspNet.Security.OAuth.Autodesk.csproj b/src/AspNet.Security.OAuth.Autodesk/AspNet.Security.OAuth.Autodesk.csproj index 79d35ec6e..1255abf88 100644 --- a/src/AspNet.Security.OAuth.Autodesk/AspNet.Security.OAuth.Autodesk.csproj +++ b/src/AspNet.Security.OAuth.Autodesk/AspNet.Security.OAuth.Autodesk.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Automatic/AspNet.Security.OAuth.Automatic.csproj b/src/AspNet.Security.OAuth.Automatic/AspNet.Security.OAuth.Automatic.csproj index 1dfc0b6d4..21f636040 100644 --- a/src/AspNet.Security.OAuth.Automatic/AspNet.Security.OAuth.Automatic.csproj +++ b/src/AspNet.Security.OAuth.Automatic/AspNet.Security.OAuth.Automatic.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Baidu/AspNet.Security.OAuth.Baidu.csproj b/src/AspNet.Security.OAuth.Baidu/AspNet.Security.OAuth.Baidu.csproj index 1b7dd2c27..9f20d7da2 100644 --- a/src/AspNet.Security.OAuth.Baidu/AspNet.Security.OAuth.Baidu.csproj +++ b/src/AspNet.Security.OAuth.Baidu/AspNet.Security.OAuth.Baidu.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Basecamp/AspNet.Security.OAuth.Basecamp.csproj b/src/AspNet.Security.OAuth.Basecamp/AspNet.Security.OAuth.Basecamp.csproj index 5e8c7a9a3..05015e553 100644 --- a/src/AspNet.Security.OAuth.Basecamp/AspNet.Security.OAuth.Basecamp.csproj +++ b/src/AspNet.Security.OAuth.Basecamp/AspNet.Security.OAuth.Basecamp.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.BattleNet/AspNet.Security.OAuth.BattleNet.csproj b/src/AspNet.Security.OAuth.BattleNet/AspNet.Security.OAuth.BattleNet.csproj index 4f4225476..f904094bd 100644 --- a/src/AspNet.Security.OAuth.BattleNet/AspNet.Security.OAuth.BattleNet.csproj +++ b/src/AspNet.Security.OAuth.BattleNet/AspNet.Security.OAuth.BattleNet.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Beam/AspNet.Security.OAuth.Beam.csproj b/src/AspNet.Security.OAuth.Beam/AspNet.Security.OAuth.Beam.csproj index fbbd94bbf..c9dc7a6d2 100644 --- a/src/AspNet.Security.OAuth.Beam/AspNet.Security.OAuth.Beam.csproj +++ b/src/AspNet.Security.OAuth.Beam/AspNet.Security.OAuth.Beam.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Bitbucket/AspNet.Security.OAuth.Bitbucket.csproj b/src/AspNet.Security.OAuth.Bitbucket/AspNet.Security.OAuth.Bitbucket.csproj index 2fe369c6f..954fe647f 100644 --- a/src/AspNet.Security.OAuth.Bitbucket/AspNet.Security.OAuth.Bitbucket.csproj +++ b/src/AspNet.Security.OAuth.Bitbucket/AspNet.Security.OAuth.Bitbucket.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs index c1adf45b7..33ecea774 100644 --- a/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs @@ -63,11 +63,11 @@ protected override async Task CreateTicketAsync( !identity.HasClaim(claim => claim.Type == ClaimTypes.Email) && Options.Scope.Contains("email")) { - string address = await GetEmailAsync(tokens); + string? address = await GetEmailAsync(tokens); if (!string.IsNullOrEmpty(address)) { - identity.AddClaim(new Claim(ClaimTypes.Email, address, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim(ClaimTypes.Email, address!, ClaimValueTypes.String, Options.ClaimsIssuer)); } } @@ -75,7 +75,7 @@ protected override async Task CreateTicketAsync( return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } - protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) + protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) { using var request = new HttpRequestMessage(HttpMethod.Get, Options.UserEmailsEndpoint); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); diff --git a/src/AspNet.Security.OAuth.Buffer/AspNet.Security.OAuth.Buffer.csproj b/src/AspNet.Security.OAuth.Buffer/AspNet.Security.OAuth.Buffer.csproj index dfb7f65e1..6471532ad 100644 --- a/src/AspNet.Security.OAuth.Buffer/AspNet.Security.OAuth.Buffer.csproj +++ b/src/AspNet.Security.OAuth.Buffer/AspNet.Security.OAuth.Buffer.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.CiscoSpark/AspNet.Security.OAuth.CiscoSpark.csproj b/src/AspNet.Security.OAuth.CiscoSpark/AspNet.Security.OAuth.CiscoSpark.csproj index 2b8fd2f7a..241956ea4 100644 --- a/src/AspNet.Security.OAuth.CiscoSpark/AspNet.Security.OAuth.CiscoSpark.csproj +++ b/src/AspNet.Security.OAuth.CiscoSpark/AspNet.Security.OAuth.CiscoSpark.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Deezer/AspNet.Security.OAuth.Deezer.csproj b/src/AspNet.Security.OAuth.Deezer/AspNet.Security.OAuth.Deezer.csproj index 50f597073..8ee404b7b 100644 --- a/src/AspNet.Security.OAuth.Deezer/AspNet.Security.OAuth.Deezer.csproj +++ b/src/AspNet.Security.OAuth.Deezer/AspNet.Security.OAuth.Deezer.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs index c2d0c6a25..1b2824646 100644 --- a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs @@ -129,7 +129,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier); using var sha256 = HashAlgorithm.Create("SHA256"); - byte[] challengeBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(codeVerifier)); + byte[] challengeBytes = sha256!.ComputeHash(Encoding.UTF8.GetBytes(codeVerifier)); parameters[OAuthConstants.CodeChallengeKey] = WebEncoders.Base64UrlEncode(challengeBytes); parameters[OAuthConstants.CodeChallengeMethodKey] = OAuthConstants.CodeChallengeMethodS256; } diff --git a/src/AspNet.Security.OAuth.DeviantArt/AspNet.Security.OAuth.DeviantArt.csproj b/src/AspNet.Security.OAuth.DeviantArt/AspNet.Security.OAuth.DeviantArt.csproj index 05b7b6b26..13e359cd7 100644 --- a/src/AspNet.Security.OAuth.DeviantArt/AspNet.Security.OAuth.DeviantArt.csproj +++ b/src/AspNet.Security.OAuth.DeviantArt/AspNet.Security.OAuth.DeviantArt.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Discord/AspNet.Security.OAuth.Discord.csproj b/src/AspNet.Security.OAuth.Discord/AspNet.Security.OAuth.Discord.csproj index 09bb26d43..89c0d3c5e 100644 --- a/src/AspNet.Security.OAuth.Discord/AspNet.Security.OAuth.Discord.csproj +++ b/src/AspNet.Security.OAuth.Discord/AspNet.Security.OAuth.Discord.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Dropbox/AspNet.Security.OAuth.Dropbox.csproj b/src/AspNet.Security.OAuth.Dropbox/AspNet.Security.OAuth.Dropbox.csproj index 01a60990c..97b54710a 100644 --- a/src/AspNet.Security.OAuth.Dropbox/AspNet.Security.OAuth.Dropbox.csproj +++ b/src/AspNet.Security.OAuth.Dropbox/AspNet.Security.OAuth.Dropbox.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.EVEOnline/AspNet.Security.OAuth.EVEOnline.csproj b/src/AspNet.Security.OAuth.EVEOnline/AspNet.Security.OAuth.EVEOnline.csproj index 03b63c2c1..0fac84db3 100644 --- a/src/AspNet.Security.OAuth.EVEOnline/AspNet.Security.OAuth.EVEOnline.csproj +++ b/src/AspNet.Security.OAuth.EVEOnline/AspNet.Security.OAuth.EVEOnline.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.ExactOnline/AspNet.Security.OAuth.ExactOnline.csproj b/src/AspNet.Security.OAuth.ExactOnline/AspNet.Security.OAuth.ExactOnline.csproj index 94baf3fef..5013c5b26 100755 --- a/src/AspNet.Security.OAuth.ExactOnline/AspNet.Security.OAuth.ExactOnline.csproj +++ b/src/AspNet.Security.OAuth.ExactOnline/AspNet.Security.OAuth.ExactOnline.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Fitbit/AspNet.Security.OAuth.Fitbit.csproj b/src/AspNet.Security.OAuth.Fitbit/AspNet.Security.OAuth.Fitbit.csproj index 40390f6df..e96cb71c7 100644 --- a/src/AspNet.Security.OAuth.Fitbit/AspNet.Security.OAuth.Fitbit.csproj +++ b/src/AspNet.Security.OAuth.Fitbit/AspNet.Security.OAuth.Fitbit.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs index 4b74fd3a2..d88877c01 100644 --- a/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs @@ -76,7 +76,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA ["code"] = context.Code }; - request.Content = new FormUrlEncodedContent(parameters); + request.Content = new FormUrlEncodedContent(parameters!); using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted); if (!response.IsSuccessStatusCode) diff --git a/src/AspNet.Security.OAuth.Foursquare/AspNet.Security.OAuth.Foursquare.csproj b/src/AspNet.Security.OAuth.Foursquare/AspNet.Security.OAuth.Foursquare.csproj index cc6d4fcea..55e1a4f80 100644 --- a/src/AspNet.Security.OAuth.Foursquare/AspNet.Security.OAuth.Foursquare.csproj +++ b/src/AspNet.Security.OAuth.Foursquare/AspNet.Security.OAuth.Foursquare.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.GitHub/AspNet.Security.OAuth.GitHub.csproj b/src/AspNet.Security.OAuth.GitHub/AspNet.Security.OAuth.GitHub.csproj index edc03081a..dd607ff2e 100644 --- a/src/AspNet.Security.OAuth.GitHub/AspNet.Security.OAuth.GitHub.csproj +++ b/src/AspNet.Security.OAuth.GitHub/AspNet.Security.OAuth.GitHub.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs b/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs index 922d54ecc..675def569 100644 --- a/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs @@ -63,7 +63,7 @@ protected override async Task CreateTicketAsync( !identity.HasClaim(claim => claim.Type == ClaimTypes.Email) && Options.Scope.Contains("user:email")) { - string address = await GetEmailAsync(tokens); + string? address = await GetEmailAsync(tokens); if (!string.IsNullOrEmpty(address)) { @@ -75,7 +75,7 @@ protected override async Task CreateTicketAsync( return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } - protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) + protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) { // See https://developer.github.com/v3/users/emails/ for more information about the /user/emails endpoint. using var request = new HttpRequestMessage(HttpMethod.Get, Options.UserEmailsEndpoint); diff --git a/src/AspNet.Security.OAuth.GitLab/AspNet.Security.OAuth.GitLab.csproj b/src/AspNet.Security.OAuth.GitLab/AspNet.Security.OAuth.GitLab.csproj index 0e2f1657c..78fa10d8c 100644 --- a/src/AspNet.Security.OAuth.GitLab/AspNet.Security.OAuth.GitLab.csproj +++ b/src/AspNet.Security.OAuth.GitLab/AspNet.Security.OAuth.GitLab.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Gitee/AspNet.Security.OAuth.Gitee.csproj b/src/AspNet.Security.OAuth.Gitee/AspNet.Security.OAuth.Gitee.csproj index 983a27995..506b774e1 100644 --- a/src/AspNet.Security.OAuth.Gitee/AspNet.Security.OAuth.Gitee.csproj +++ b/src/AspNet.Security.OAuth.Gitee/AspNet.Security.OAuth.Gitee.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs index b73f85c96..de5263d41 100644 --- a/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs @@ -27,8 +27,8 @@ public GiteeAuthenticationHandler( [NotNull] UrlEncoder encoder, [NotNull] ISystemClock clock) : base(options, logger, encoder, clock) - { - } + { + } protected override async Task CreateTicketAsync( [NotNull] ClaimsIdentity identity, @@ -63,7 +63,7 @@ protected override async Task CreateTicketAsync( !identity.HasClaim(claim => claim.Type == ClaimTypes.Email) && Options.Scope.Contains("emails")) { - string address = await GetEmailAsync(tokens); + string? address = await GetEmailAsync(tokens); if (!string.IsNullOrEmpty(address)) { @@ -75,7 +75,7 @@ protected override async Task CreateTicketAsync( return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } - protected async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) + protected async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) { using var request = new HttpRequestMessage(HttpMethod.Get, Options.UserEmailsEndpoint); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); diff --git a/src/AspNet.Security.OAuth.Gitter/AspNet.Security.OAuth.Gitter.csproj b/src/AspNet.Security.OAuth.Gitter/AspNet.Security.OAuth.Gitter.csproj index 39c295f51..bd6848f80 100644 --- a/src/AspNet.Security.OAuth.Gitter/AspNet.Security.OAuth.Gitter.csproj +++ b/src/AspNet.Security.OAuth.Gitter/AspNet.Security.OAuth.Gitter.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Harvest/AspNet.Security.OAuth.Harvest.csproj b/src/AspNet.Security.OAuth.Harvest/AspNet.Security.OAuth.Harvest.csproj index 2805172c2..5008e9011 100644 --- a/src/AspNet.Security.OAuth.Harvest/AspNet.Security.OAuth.Harvest.csproj +++ b/src/AspNet.Security.OAuth.Harvest/AspNet.Security.OAuth.Harvest.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.HealthGraph/AspNet.Security.OAuth.HealthGraph.csproj b/src/AspNet.Security.OAuth.HealthGraph/AspNet.Security.OAuth.HealthGraph.csproj index d0661cee1..1309c122c 100644 --- a/src/AspNet.Security.OAuth.HealthGraph/AspNet.Security.OAuth.HealthGraph.csproj +++ b/src/AspNet.Security.OAuth.HealthGraph/AspNet.Security.OAuth.HealthGraph.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Imgur/AspNet.Security.OAuth.Imgur.csproj b/src/AspNet.Security.OAuth.Imgur/AspNet.Security.OAuth.Imgur.csproj index d40184f13..f477103c9 100644 --- a/src/AspNet.Security.OAuth.Imgur/AspNet.Security.OAuth.Imgur.csproj +++ b/src/AspNet.Security.OAuth.Imgur/AspNet.Security.OAuth.Imgur.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Instagram/AspNet.Security.OAuth.Instagram.csproj b/src/AspNet.Security.OAuth.Instagram/AspNet.Security.OAuth.Instagram.csproj index d46f76ecd..34af630be 100644 --- a/src/AspNet.Security.OAuth.Instagram/AspNet.Security.OAuth.Instagram.csproj +++ b/src/AspNet.Security.OAuth.Instagram/AspNet.Security.OAuth.Instagram.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs index 400602dcf..141dc2164 100644 --- a/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs @@ -67,11 +67,5 @@ protected override async Task CreateTicketAsync( await Options.Events.CreatingTicket(context); return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } - - [Obsolete("This method is no longer called and will be removed in a future version.")] - protected virtual string ComputeSignature([NotNull] string address) - { - return string.Empty; - } } } diff --git a/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationOptions.cs b/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationOptions.cs index 222d37c66..d80f395c1 100644 --- a/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationOptions.cs @@ -35,16 +35,6 @@ public InstagramAuthenticationOptions() ClaimActions.MapJsonKey(Claims.MediaCount, "media_count"); } - /// - /// Gets or sets a boolean indicating whether requests to the - /// URL specified by - /// should be signed before being sent to the Instagram API. - /// Enabling this option is recommended when the client application - /// has been configured to enforce signed requests. - /// - [Obsolete("This property no longer has any effect and will be removed in a future version.")] - public bool UseSignedRequests { get; set; } - /// /// Gets the list of list of fields and edges to retrieve from the user information endpoint. /// diff --git a/src/AspNet.Security.OAuth.LinkedIn/AspNet.Security.OAuth.LinkedIn.csproj b/src/AspNet.Security.OAuth.LinkedIn/AspNet.Security.OAuth.LinkedIn.csproj index e0fff487d..dc50e0532 100644 --- a/src/AspNet.Security.OAuth.LinkedIn/AspNet.Security.OAuth.LinkedIn.csproj +++ b/src/AspNet.Security.OAuth.LinkedIn/AspNet.Security.OAuth.LinkedIn.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs index 5fd9581e2..141ffbe99 100644 --- a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs @@ -72,7 +72,7 @@ public LinkedInAuthenticationOptions() /// 3. Returns the first value. /// /// - public Func, string?, string> MultiLocaleStringResolver { get; set; } = DefaultMultiLocaleStringResolver; + public Func, string?, string?> MultiLocaleStringResolver { get; set; } = DefaultMultiLocaleStringResolver; /// /// Gets the MultiLocaleString value using the configured resolver. @@ -100,7 +100,7 @@ public LinkedInAuthenticationOptions() preferredLocaleKey = $"{preferredLocale.GetString("language")}_{preferredLocale.GetString("country")}"; } - var preferredLocales = new Dictionary(); + var preferredLocales = new Dictionary(); foreach (var element in propertyLocalized.EnumerateObject()) { @@ -164,7 +164,7 @@ private static IEnumerable GetPictureUrls(JsonElement user) /// The localized values with culture keys. /// The preferred locale, if provided by LinkedIn. /// The localized value. - private static string DefaultMultiLocaleStringResolver(IReadOnlyDictionary localizedValues, string? preferredLocale) + private static string? DefaultMultiLocaleStringResolver(IReadOnlyDictionary localizedValues, string? preferredLocale) { if (!string.IsNullOrEmpty(preferredLocale) && localizedValues.TryGetValue(preferredLocale, out string? preferredLocaleValue)) diff --git a/src/AspNet.Security.OAuth.MailChimp/AspNet.Security.OAuth.MailChimp.csproj b/src/AspNet.Security.OAuth.MailChimp/AspNet.Security.OAuth.MailChimp.csproj index 54f6bc895..49a63a60a 100644 --- a/src/AspNet.Security.OAuth.MailChimp/AspNet.Security.OAuth.MailChimp.csproj +++ b/src/AspNet.Security.OAuth.MailChimp/AspNet.Security.OAuth.MailChimp.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.MailRu/AspNet.Security.OAuth.MailRu.csproj b/src/AspNet.Security.OAuth.MailRu/AspNet.Security.OAuth.MailRu.csproj index 976db083f..8cbc9a0a9 100644 --- a/src/AspNet.Security.OAuth.MailRu/AspNet.Security.OAuth.MailRu.csproj +++ b/src/AspNet.Security.OAuth.MailRu/AspNet.Security.OAuth.MailRu.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Myob/AspNet.Security.OAuth.Myob.csproj b/src/AspNet.Security.OAuth.Myob/AspNet.Security.OAuth.Myob.csproj index 0cadd4a87..3b00ee4af 100644 --- a/src/AspNet.Security.OAuth.Myob/AspNet.Security.OAuth.Myob.csproj +++ b/src/AspNet.Security.OAuth.Myob/AspNet.Security.OAuth.Myob.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.NetEase/AspNet.Security.OAuth.NetEase.csproj b/src/AspNet.Security.OAuth.NetEase/AspNet.Security.OAuth.NetEase.csproj index 7f98c12ab..447750635 100644 --- a/src/AspNet.Security.OAuth.NetEase/AspNet.Security.OAuth.NetEase.csproj +++ b/src/AspNet.Security.OAuth.NetEase/AspNet.Security.OAuth.NetEase.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Nextcloud/AspNet.Security.OAuth.Nextcloud.csproj b/src/AspNet.Security.OAuth.Nextcloud/AspNet.Security.OAuth.Nextcloud.csproj index 823f66de7..c7bb680b8 100644 --- a/src/AspNet.Security.OAuth.Nextcloud/AspNet.Security.OAuth.Nextcloud.csproj +++ b/src/AspNet.Security.OAuth.Nextcloud/AspNet.Security.OAuth.Nextcloud.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Odnoklassniki/AspNet.Security.OAuth.Odnoklassniki.csproj b/src/AspNet.Security.OAuth.Odnoklassniki/AspNet.Security.OAuth.Odnoklassniki.csproj index 9091f5f7f..f1757b370 100644 --- a/src/AspNet.Security.OAuth.Odnoklassniki/AspNet.Security.OAuth.Odnoklassniki.csproj +++ b/src/AspNet.Security.OAuth.Odnoklassniki/AspNet.Security.OAuth.Odnoklassniki.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs index 51862bfe1..af8cc60f5 100644 --- a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs @@ -40,8 +40,8 @@ protected override async Task CreateTicketAsync( [NotNull] OAuthTokenResponse tokens) { using var algorithm = HashAlgorithm.Create("MD5"); - string accessSecret = GetHash(algorithm, tokens.AccessToken + Options.ClientSecret); - string sign = GetHash(algorithm, $"application_key={Options.PublicSecret}format=jsonmethod=users.getCurrentUser{accessSecret}"); + string accessSecret = GetHash(algorithm!, tokens.AccessToken + Options.ClientSecret); + string sign = GetHash(algorithm!, $"application_key={Options.PublicSecret}format=jsonmethod=users.getCurrentUser{accessSecret}"); string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { diff --git a/src/AspNet.Security.OAuth.Okta/AspNet.Security.OAuth.Okta.csproj b/src/AspNet.Security.OAuth.Okta/AspNet.Security.OAuth.Okta.csproj index 5c47d5913..958314f13 100644 --- a/src/AspNet.Security.OAuth.Okta/AspNet.Security.OAuth.Okta.csproj +++ b/src/AspNet.Security.OAuth.Okta/AspNet.Security.OAuth.Okta.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Onshape/AspNet.Security.OAuth.Onshape.csproj b/src/AspNet.Security.OAuth.Onshape/AspNet.Security.OAuth.Onshape.csproj index 6d2917068..611c080a3 100644 --- a/src/AspNet.Security.OAuth.Onshape/AspNet.Security.OAuth.Onshape.csproj +++ b/src/AspNet.Security.OAuth.Onshape/AspNet.Security.OAuth.Onshape.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Patreon/AspNet.Security.OAuth.Patreon.csproj b/src/AspNet.Security.OAuth.Patreon/AspNet.Security.OAuth.Patreon.csproj index 09dfc33aa..665c14e18 100644 --- a/src/AspNet.Security.OAuth.Patreon/AspNet.Security.OAuth.Patreon.csproj +++ b/src/AspNet.Security.OAuth.Patreon/AspNet.Security.OAuth.Patreon.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Paypal/AspNet.Security.OAuth.Paypal.csproj b/src/AspNet.Security.OAuth.Paypal/AspNet.Security.OAuth.Paypal.csproj index 893e36f6a..babb0b2fa 100644 --- a/src/AspNet.Security.OAuth.Paypal/AspNet.Security.OAuth.Paypal.csproj +++ b/src/AspNet.Security.OAuth.Paypal/AspNet.Security.OAuth.Paypal.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.QQ/AspNet.Security.OAuth.QQ.csproj b/src/AspNet.Security.OAuth.QQ/AspNet.Security.OAuth.QQ.csproj index 3b02b3972..0cbfb3851 100644 --- a/src/AspNet.Security.OAuth.QQ/AspNet.Security.OAuth.QQ.csproj +++ b/src/AspNet.Security.OAuth.QQ/AspNet.Security.OAuth.QQ.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Reddit/AspNet.Security.OAuth.Reddit.csproj b/src/AspNet.Security.OAuth.Reddit/AspNet.Security.OAuth.Reddit.csproj index 92b9f4094..d51850dbf 100644 --- a/src/AspNet.Security.OAuth.Reddit/AspNet.Security.OAuth.Reddit.csproj +++ b/src/AspNet.Security.OAuth.Reddit/AspNet.Security.OAuth.Reddit.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs index bbff95f56..0db09076e 100644 --- a/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs @@ -108,7 +108,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA ["code"] = context.Code }; - request.Content = new FormUrlEncodedContent(parameters); + request.Content = new FormUrlEncodedContent(parameters!); using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted); if (!response.IsSuccessStatusCode) diff --git a/src/AspNet.Security.OAuth.Salesforce/AspNet.Security.OAuth.Salesforce.csproj b/src/AspNet.Security.OAuth.Salesforce/AspNet.Security.OAuth.Salesforce.csproj index 1dd2026d6..a3ff5d743 100644 --- a/src/AspNet.Security.OAuth.Salesforce/AspNet.Security.OAuth.Salesforce.csproj +++ b/src/AspNet.Security.OAuth.Salesforce/AspNet.Security.OAuth.Salesforce.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Shopify/AspNet.Security.OAuth.Shopify.csproj b/src/AspNet.Security.OAuth.Shopify/AspNet.Security.OAuth.Shopify.csproj index 18e0fc42b..d1a07ff5b 100644 --- a/src/AspNet.Security.OAuth.Shopify/AspNet.Security.OAuth.Shopify.csproj +++ b/src/AspNet.Security.OAuth.Shopify/AspNet.Security.OAuth.Shopify.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs index 8e4b69e1a..75ff074ef 100644 --- a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs @@ -186,7 +186,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA ["code"] = context.Code }; - request.Content = new FormUrlEncodedContent(parameters); + request.Content = new FormUrlEncodedContent(parameters!); using var response = await Backchannel.SendAsync(request, Context.RequestAborted); diff --git a/src/AspNet.Security.OAuth.Slack/AspNet.Security.OAuth.Slack.csproj b/src/AspNet.Security.OAuth.Slack/AspNet.Security.OAuth.Slack.csproj index 62765c31f..03b60a6eb 100644 --- a/src/AspNet.Security.OAuth.Slack/AspNet.Security.OAuth.Slack.csproj +++ b/src/AspNet.Security.OAuth.Slack/AspNet.Security.OAuth.Slack.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.SoundCloud/AspNet.Security.OAuth.SoundCloud.csproj b/src/AspNet.Security.OAuth.SoundCloud/AspNet.Security.OAuth.SoundCloud.csproj index 3658b267f..c69a8b5d9 100644 --- a/src/AspNet.Security.OAuth.SoundCloud/AspNet.Security.OAuth.SoundCloud.csproj +++ b/src/AspNet.Security.OAuth.SoundCloud/AspNet.Security.OAuth.SoundCloud.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Spotify/AspNet.Security.OAuth.Spotify.csproj b/src/AspNet.Security.OAuth.Spotify/AspNet.Security.OAuth.Spotify.csproj index 92d3d34b6..adaa3fac0 100644 --- a/src/AspNet.Security.OAuth.Spotify/AspNet.Security.OAuth.Spotify.csproj +++ b/src/AspNet.Security.OAuth.Spotify/AspNet.Security.OAuth.Spotify.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.StackExchange/AspNet.Security.OAuth.StackExchange.csproj b/src/AspNet.Security.OAuth.StackExchange/AspNet.Security.OAuth.StackExchange.csproj index 0667947c0..2149242dc 100644 --- a/src/AspNet.Security.OAuth.StackExchange/AspNet.Security.OAuth.StackExchange.csproj +++ b/src/AspNet.Security.OAuth.StackExchange/AspNet.Security.OAuth.StackExchange.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs index 3130b4f23..7e1c3c9d7 100644 --- a/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs @@ -96,7 +96,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA using var request = new HttpRequestMessage(HttpMethod.Post, Options.TokenEndpoint) { - Content = new FormUrlEncodedContent(parameters) + Content = new FormUrlEncodedContent(parameters!) }; using var response = await Backchannel.SendAsync(request, Context.RequestAborted); diff --git a/src/AspNet.Security.OAuth.Strava/AspNet.Security.OAuth.Strava.csproj b/src/AspNet.Security.OAuth.Strava/AspNet.Security.OAuth.Strava.csproj index 932abbb32..cb8ff060b 100644 --- a/src/AspNet.Security.OAuth.Strava/AspNet.Security.OAuth.Strava.csproj +++ b/src/AspNet.Security.OAuth.Strava/AspNet.Security.OAuth.Strava.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.SuperOffice/AspNet.Security.OAuth.SuperOffice.csproj b/src/AspNet.Security.OAuth.SuperOffice/AspNet.Security.OAuth.SuperOffice.csproj index f50fdd382..300df3796 100644 --- a/src/AspNet.Security.OAuth.SuperOffice/AspNet.Security.OAuth.SuperOffice.csproj +++ b/src/AspNet.Security.OAuth.SuperOffice/AspNet.Security.OAuth.SuperOffice.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeFunctionalRightsClaimAction.cs b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeFunctionalRightsClaimAction.cs index a3ad04bcc..8b02fc76b 100644 --- a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeFunctionalRightsClaimAction.cs +++ b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeFunctionalRightsClaimAction.cs @@ -34,7 +34,7 @@ public override void Run(JsonElement userData, ClaimsIdentity identity, string i { foreach (var functionRight in functionRights.EnumerateArray()) { - identity.AddClaim(new Claim(SuperOfficeAuthenticationConstants.PrincipalNames.FunctionRights, functionRight.GetString())); + identity.AddClaim(new Claim(SuperOfficeAuthenticationConstants.PrincipalNames.FunctionRights, functionRight.GetString() ?? string.Empty)); } } } diff --git a/src/AspNet.Security.OAuth.Trakt/AspNet.Security.OAuth.Trakt.csproj b/src/AspNet.Security.OAuth.Trakt/AspNet.Security.OAuth.Trakt.csproj index e1b772247..357d01bdf 100644 --- a/src/AspNet.Security.OAuth.Trakt/AspNet.Security.OAuth.Trakt.csproj +++ b/src/AspNet.Security.OAuth.Trakt/AspNet.Security.OAuth.Trakt.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Twitch/AspNet.Security.OAuth.Twitch.csproj b/src/AspNet.Security.OAuth.Twitch/AspNet.Security.OAuth.Twitch.csproj index 2b8b94ee1..eba96f077 100644 --- a/src/AspNet.Security.OAuth.Twitch/AspNet.Security.OAuth.Twitch.csproj +++ b/src/AspNet.Security.OAuth.Twitch/AspNet.Security.OAuth.Twitch.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Untappd/AspNet.Security.OAuth.Untappd.csproj b/src/AspNet.Security.OAuth.Untappd/AspNet.Security.OAuth.Untappd.csproj index 20f075da7..b168b4a70 100644 --- a/src/AspNet.Security.OAuth.Untappd/AspNet.Security.OAuth.Untappd.csproj +++ b/src/AspNet.Security.OAuth.Untappd/AspNet.Security.OAuth.Untappd.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Vimeo/AspNet.Security.OAuth.Vimeo.csproj b/src/AspNet.Security.OAuth.Vimeo/AspNet.Security.OAuth.Vimeo.csproj index 188fedc81..95f972634 100644 --- a/src/AspNet.Security.OAuth.Vimeo/AspNet.Security.OAuth.Vimeo.csproj +++ b/src/AspNet.Security.OAuth.Vimeo/AspNet.Security.OAuth.Vimeo.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.VisualStudio/AspNet.Security.OAuth.VisualStudio.csproj b/src/AspNet.Security.OAuth.VisualStudio/AspNet.Security.OAuth.VisualStudio.csproj index 0e7ee010e..86a7e8f20 100644 --- a/src/AspNet.Security.OAuth.VisualStudio/AspNet.Security.OAuth.VisualStudio.csproj +++ b/src/AspNet.Security.OAuth.VisualStudio/AspNet.Security.OAuth.VisualStudio.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs index 4cde9c20f..3f8f00db0 100644 --- a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs @@ -77,7 +77,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA ["client_assertion_type"] = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" }; - request.Content = new FormUrlEncodedContent(parameters); + request.Content = new FormUrlEncodedContent(parameters!); using var response = await Backchannel.SendAsync(request, Context.RequestAborted); diff --git a/src/AspNet.Security.OAuth.Vkontakte/AspNet.Security.OAuth.Vkontakte.csproj b/src/AspNet.Security.OAuth.Vkontakte/AspNet.Security.OAuth.Vkontakte.csproj index a573f781b..221a41609 100644 --- a/src/AspNet.Security.OAuth.Vkontakte/AspNet.Security.OAuth.Vkontakte.csproj +++ b/src/AspNet.Security.OAuth.Vkontakte/AspNet.Security.OAuth.Vkontakte.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Weibo/AspNet.Security.OAuth.Weibo.csproj b/src/AspNet.Security.OAuth.Weibo/AspNet.Security.OAuth.Weibo.csproj index 920025182..816fe4d58 100644 --- a/src/AspNet.Security.OAuth.Weibo/AspNet.Security.OAuth.Weibo.csproj +++ b/src/AspNet.Security.OAuth.Weibo/AspNet.Security.OAuth.Weibo.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs index 666178dd2..a3e9e92bc 100644 --- a/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs @@ -66,11 +66,11 @@ protected override async Task CreateTicketAsync( !identity.HasClaim(claim => claim.Type == ClaimTypes.Email) && Options.Scope.Contains("email")) { - string email = await GetEmailAsync(tokens); + string? email = await GetEmailAsync(tokens); if (!string.IsNullOrEmpty(address)) { - identity.AddClaim(new Claim(ClaimTypes.Email, email, ClaimValueTypes.String, Options.ClaimsIssuer)); + identity.AddClaim(new Claim(ClaimTypes.Email, email!, ClaimValueTypes.String, Options.ClaimsIssuer)); } } @@ -84,7 +84,7 @@ protected override async Task CreateTicketAsync( protected override string FormatScope() => string.Join(",", Options.Scope); - protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) + protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) { // See http://open.weibo.com/wiki/2/account/profile/email for more information about the /account/profile/email.json endpoint. string address = QueryHelpers.AddQueryString(Options.UserEmailsEndpoint, "access_token", tokens.AccessToken); diff --git a/src/AspNet.Security.OAuth.Weixin/AspNet.Security.OAuth.Weixin.csproj b/src/AspNet.Security.OAuth.Weixin/AspNet.Security.OAuth.Weixin.csproj index 43321ac43..65d2da3a4 100644 --- a/src/AspNet.Security.OAuth.Weixin/AspNet.Security.OAuth.Weixin.csproj +++ b/src/AspNet.Security.OAuth.Weixin/AspNet.Security.OAuth.Weixin.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.WordPress/AspNet.Security.OAuth.WordPress.csproj b/src/AspNet.Security.OAuth.WordPress/AspNet.Security.OAuth.WordPress.csproj index d0dd44559..22bd67158 100644 --- a/src/AspNet.Security.OAuth.WordPress/AspNet.Security.OAuth.WordPress.csproj +++ b/src/AspNet.Security.OAuth.WordPress/AspNet.Security.OAuth.WordPress.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Yahoo/AspNet.Security.OAuth.Yahoo.csproj b/src/AspNet.Security.OAuth.Yahoo/AspNet.Security.OAuth.Yahoo.csproj index 0b9aea5ce..1dbbcca74 100644 --- a/src/AspNet.Security.OAuth.Yahoo/AspNet.Security.OAuth.Yahoo.csproj +++ b/src/AspNet.Security.OAuth.Yahoo/AspNet.Security.OAuth.Yahoo.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationConstants.cs b/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationConstants.cs index d0a698d95..c005fe0c1 100644 --- a/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationConstants.cs +++ b/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationConstants.cs @@ -17,10 +17,6 @@ public static class Claims { public const string FamilyName = "urn:yahoo:familyname"; public const string GivenName = "urn:yahoo:givenname"; - [Obsolete("This has been deprecated. Please use Picture instead. See https://developer.yahoo.com/oauth/social-directory-eol/ for more information.")] - public const string ImageUrl = "urn:yahoo:profileimage"; - [Obsolete("This has been deprecated. See https://developer.yahoo.com/oauth/social-directory-eol/ for more information.")] - public const string ProfileUrl = "urn:yahoo:profile"; public const string Picture = "urn:yahoo:picture"; } } diff --git a/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs index bb4629c5d..e1a0847e4 100644 --- a/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs @@ -76,7 +76,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA ["code"] = context.Code }; - request.Content = new FormUrlEncodedContent(parameters); + request.Content = new FormUrlEncodedContent(parameters!); using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted); if (!response.IsSuccessStatusCode) diff --git a/src/AspNet.Security.OAuth.Yammer/AspNet.Security.OAuth.Yammer.csproj b/src/AspNet.Security.OAuth.Yammer/AspNet.Security.OAuth.Yammer.csproj index 5b5e3d2e1..ac05d7db8 100644 --- a/src/AspNet.Security.OAuth.Yammer/AspNet.Security.OAuth.Yammer.csproj +++ b/src/AspNet.Security.OAuth.Yammer/AspNet.Security.OAuth.Yammer.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs index 41921452e..c682a3238 100644 --- a/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs @@ -77,7 +77,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA ["grant_type"] = "authorization_code" }; - request.Content = new FormUrlEncodedContent(parameters); + request.Content = new FormUrlEncodedContent(parameters!); using var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) diff --git a/src/AspNet.Security.OAuth.Yandex/AspNet.Security.OAuth.Yandex.csproj b/src/AspNet.Security.OAuth.Yandex/AspNet.Security.OAuth.Yandex.csproj index 11f9d3cb3..9be4cfaa8 100644 --- a/src/AspNet.Security.OAuth.Yandex/AspNet.Security.OAuth.Yandex.csproj +++ b/src/AspNet.Security.OAuth.Yandex/AspNet.Security.OAuth.Yandex.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs index 72cf5e81f..2c3508cfc 100644 --- a/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs @@ -76,7 +76,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA ["code"] = context.Code }; - request.Content = new FormUrlEncodedContent(parameters); + request.Content = new FormUrlEncodedContent(parameters!); using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted); if (!response.IsSuccessStatusCode) diff --git a/src/AspNet.Security.OAuth.Zalo/AspNet.Security.OAuth.Zalo.csproj b/src/AspNet.Security.OAuth.Zalo/AspNet.Security.OAuth.Zalo.csproj index 5360dd9df..fa616a036 100644 --- a/src/AspNet.Security.OAuth.Zalo/AspNet.Security.OAuth.Zalo.csproj +++ b/src/AspNet.Security.OAuth.Zalo/AspNet.Security.OAuth.Zalo.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj b/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj index e80427c91..18fdcfbb4 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj +++ b/test/AspNet.Security.OAuth.Providers.Tests/AspNet.Security.OAuth.Providers.Tests.csproj @@ -2,7 +2,7 @@ AspNet.Security.OAuth - netcoreapp3.1 + net5.0 false true $(NoWarn);CA1707;CA2227 diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs b/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs index 62d5cc095..bbc7ec0ef 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs @@ -102,7 +102,7 @@ private static void ConfigureApplication(IApplicationBuilder app, OAut "/me", async context => { - if (context.User.Identity.IsAuthenticated) + if (context.User.Identity?.IsAuthenticated == true) { string xml = IdentityToXmlString(context.User); byte[] buffer = Encoding.UTF8.GetBytes(xml); diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/LoopbackRedirectHandler.cs b/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/LoopbackRedirectHandler.cs index 1d6a56e1e..f49133694 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/LoopbackRedirectHandler.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/LoopbackRedirectHandler.cs @@ -40,9 +40,9 @@ protected override async Task SendAsync(HttpRequestMessage if (RedirectMethod == HttpMethod.Post) { var queryString = HttpUtility.ParseQueryString(result.Headers.Location!.Query); - string state = queryString["state"]; + string? state = queryString["state"]; - var parameters = new Dictionary() + var parameters = new Dictionary() { ["code"] = "a6ed8e7f-471f-44f1-903b-65946475f351", ["state"] = state, @@ -56,7 +56,7 @@ protected override async Task SendAsync(HttpRequestMessage } } - content = new FormUrlEncodedContent(parameters); + content = new FormUrlEncodedContent(parameters!); } else { @@ -89,17 +89,17 @@ protected virtual Uri BuildLoopbackUri(HttpResponseMessage responseMessage) { // Rewrite the URI to loop back to the redirected URL to simulate the user having // successfully authenticated with the external login page they were redirected to. - var queryString = HttpUtility.ParseQueryString(responseMessage.Headers.Location.Query); + var queryString = HttpUtility.ParseQueryString(responseMessage.Headers.Location!.Query); string? location = queryString["redirect_uri"] ?? RedirectUri; - string state = queryString["state"]; + string? state = queryString["state"]; var builder = new UriBuilder(location!); // Retain the _oauthstate parameter in redirect_uri for WeChat (see #262) const string OAuthStateKey = "_oauthstate"; var redirectQuery = HttpUtility.ParseQueryString(builder.Query); - string oauthState = redirectQuery[OAuthStateKey]; + string? oauthState = redirectQuery[OAuthStateKey]; // Remove any query string parameters we do not explictly need to retain queryString.Clear(); diff --git a/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs b/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs index 90c7596db..aa9bbe6ee 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs @@ -204,7 +204,8 @@ protected async Task> AuthenticateUserAsync(WebApplic // Assert result.StatusCode.ShouldBe(HttpStatusCode.OK); - result.Content.Headers.ContentType.MediaType.ShouldBe("text/xml"); + result.Content.Headers.ContentType.ShouldNotBeNull(); + result.Content.Headers.ContentType!.MediaType.ShouldBe("text/xml"); string xml = await result.Content.ReadAsStringAsync(); From 4377732ff02bf6ad0f3a55ceaaaa3cfab1952f0b Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 21 Jul 2020 20:43:40 +0100 Subject: [PATCH 2/6] Update to ASP.NET 5 preview 7 Update to preview 5 of ASP.NET 5. --- Directory.Packages.props | 8 ++++---- global.json | 2 +- .../AppleAuthenticationEvents.cs | 2 +- .../ArcGISAuthenticationHandler.cs | 2 +- .../AutomaticAuthenticationHandler.cs | 2 +- .../DeezerAuthenticationHandler.cs | 4 ++-- .../FoursquareAuthenticationHandler.cs | 2 +- .../OdnoklassnikiAuthenticationHandler.cs | 2 +- src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs | 4 ++-- .../ShopifyAuthenticationHandler.cs | 4 ++-- .../ShopifyAuthenticationProperties.cs | 4 ++-- .../StackExchangeAuthenticationHandler.cs | 3 ++- .../TwitchAuthenticationHandler.cs | 2 +- .../VisualStudioAuthenticationHandler.cs | 2 +- .../VkontakteAuthenticationHandler.cs | 2 +- .../WeiboAuthenticationHandler.cs | 2 +- .../WeixinAuthenticationHandler.cs | 6 +++--- .../ZaloAuthenticationHandler.cs | 4 ++-- 18 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 273577462..d34f785e2 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,10 +4,10 @@ - - - - + + + + diff --git a/global.json b/global.json index 0a29fa16f..1d48306fd 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-preview.6.20318.15" + "dotnet": "5.0.100-preview.7.20366.6" }, "msbuild-sdks": { diff --git a/src/AspNet.Security.OAuth.Apple/AppleAuthenticationEvents.cs b/src/AspNet.Security.OAuth.Apple/AppleAuthenticationEvents.cs index 574680ee3..63b57f46a 100644 --- a/src/AspNet.Security.OAuth.Apple/AppleAuthenticationEvents.cs +++ b/src/AspNet.Security.OAuth.Apple/AppleAuthenticationEvents.cs @@ -22,7 +22,7 @@ public class AppleAuthenticationEvents : OAuthEvents /// public Func OnGenerateClientSecret { get; set; } = async context => { - var provider = context.HttpContext.RequestServices.GetService(); + var provider = context.HttpContext!.RequestServices!.GetRequiredService(); context.Options.ClientSecret = await provider.GenerateAsync(context); }; diff --git a/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs b/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs index bfde09178..ac944cb41 100644 --- a/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs @@ -38,7 +38,7 @@ protected override async Task CreateTicketAsync( [NotNull] OAuthTokenResponse tokens) { // Note: the ArcGIS API doesn't support content negotiation via headers. - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["f"] = "json", ["token"] = tokens.AccessToken diff --git a/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs index d36eab2f1..e516d9e64 100644 --- a/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs @@ -65,7 +65,7 @@ protected override async Task CreateTicketAsync( protected override string BuildChallengeUrl([NotNull] AuthenticationProperties properties, [NotNull] string redirectUri) { // Note: the redirect_uri parameter is not allowed by Automatic and MUST NOT be sent. - return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary + return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary { ["client_id"] = Options.ClientId, ["response_type"] = "code", diff --git a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs index 1b2824646..522b88e73 100644 --- a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs @@ -37,7 +37,7 @@ public DeezerAuthenticationHandler( protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) { - var tokenRequestParameters = new Dictionary() + var tokenRequestParameters = new Dictionary() { ["app_id"] = Options.ClientId, ["secret"] = Options.ClientSecret, @@ -112,7 +112,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p var scopeParameter = properties.GetParameter>(OAuthChallengeProperties.ScopeKey); string scopes = scopeParameter != null ? FormatScope(scopeParameter) : FormatScope(); - var parameters = new Dictionary + var parameters = new Dictionary { ["app_id"] = Options.ClientId, ["redirect_uri"] = redirectUri, diff --git a/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs index 838b00848..c2c7145fd 100644 --- a/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs @@ -37,7 +37,7 @@ protected override async Task CreateTicketAsync( { // See https://developer.foursquare.com/overview/versioning // for more information about the mandatory "v" and "m" parameters. - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["m"] = "foursquare", ["v"] = !string.IsNullOrEmpty(Options.ApiVersion) ? Options.ApiVersion : FoursquareAuthenticationDefaults.ApiVersion, diff --git a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs index af8cc60f5..1c326b902 100644 --- a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs @@ -43,7 +43,7 @@ protected override async Task CreateTicketAsync( string accessSecret = GetHash(algorithm!, tokens.AccessToken + Options.ClientSecret); string sign = GetHash(algorithm!, $"application_key={Options.PublicSecret}format=jsonmethod=users.getCurrentUser{accessSecret}"); - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["application_key"] = Options.PublicSecret ?? string.Empty, ["format"] = "json", diff --git a/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs b/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs index 64b41d895..93000b905 100644 --- a/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs @@ -46,7 +46,7 @@ protected override async Task CreateTicketAsync( identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, identifier, ClaimValueTypes.String, Options.ClaimsIssuer)); - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["oauth_consumer_key"] = Options.ClientId, ["access_token"] = tokens.AccessToken, @@ -88,7 +88,7 @@ protected override async Task CreateTicketAsync( protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) { - string address = QueryHelpers.AddQueryString(Options.TokenEndpoint, new Dictionary() + string address = QueryHelpers.AddQueryString(Options.TokenEndpoint, new Dictionary() { ["client_id"] = Options.ClientId, ["client_secret"] = Options.ClientSecret, diff --git a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs index 75ff074ef..2256559c7 100644 --- a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs @@ -118,7 +118,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p scope = FormatScope(); } - string url = QueryHelpers.AddQueryString(uri, new Dictionary() + string url = QueryHelpers.AddQueryString(uri, new Dictionary() { ["client_id"] = Options.ClientId, ["scope"] = scope, @@ -161,7 +161,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA // request the token. This probably isn't necessary, but it's an easy extra verification. var authenticationProperties = Options.StateDataFormat.Unprotect(stateValue); - string shopNamePropertyValue = authenticationProperties.Items[ShopifyAuthenticationDefaults.ShopNameAuthenticationProperty]; + string? shopNamePropertyValue = authenticationProperties.Items[ShopifyAuthenticationDefaults.ShopNameAuthenticationProperty]; if (!string.Equals(shopNamePropertyValue, shopDns, StringComparison.OrdinalIgnoreCase)) { diff --git a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationProperties.cs b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationProperties.cs index 15c419630..09ab6d7fb 100644 --- a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationProperties.cs +++ b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationProperties.cs @@ -26,7 +26,7 @@ public class ShopifyAuthenticationProperties : AuthenticationProperties /// installation. /// public ShopifyAuthenticationProperties(string shopName) - : this(shopName, null) + : this(shopName, new Dictionary()) { } @@ -38,7 +38,7 @@ public ShopifyAuthenticationProperties(string shopName) /// installation. /// /// Set Items values. - public ShopifyAuthenticationProperties(string shopName, IDictionary? items) + public ShopifyAuthenticationProperties(string shopName, IDictionary items) : base(items) { SetShopName(shopName); diff --git a/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs index 7e1c3c9d7..7902d03e5 100644 --- a/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs @@ -46,11 +46,12 @@ protected override async Task CreateTicketAsync( $"No site was specified for the {nameof(StackExchangeAuthenticationOptions.Site)} property of {nameof(StackExchangeAuthenticationOptions)}."); } - var queryArguments = new Dictionary + var queryArguments = new Dictionary { ["access_token"] = tokens.AccessToken, ["site"] = Options.Site, }; + if (!string.IsNullOrEmpty(Options.RequestKey)) { queryArguments["key"] = Options.RequestKey; diff --git a/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs index a39247511..c46226a1d 100644 --- a/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs @@ -32,7 +32,7 @@ public TwitchAuthenticationHandler( } protected override string BuildChallengeUrl([NotNull] AuthenticationProperties properties, [NotNull] string redirectUri) - => QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary + => QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary { ["client_id"] = Options.ClientId, ["scope"] = FormatScope(), diff --git a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs index 3f8f00db0..1e366b708 100644 --- a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs @@ -99,7 +99,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA protected override string BuildChallengeUrl([NotNull] AuthenticationProperties properties, [NotNull] string redirectUri) { - return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary + return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary { ["client_id"] = Options.ClientId, ["response_type"] = "Assertion", diff --git a/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs index 718394be7..62fc62423 100644 --- a/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs @@ -36,7 +36,7 @@ protected override async Task CreateTicketAsync( [NotNull] AuthenticationProperties properties, [NotNull] OAuthTokenResponse tokens) { - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["access_token"] = tokens.AccessToken, ["v"] = !string.IsNullOrEmpty(Options.ApiVersion) ? Options.ApiVersion : VkontakteAuthenticationDefaults.ApiVersion diff --git a/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs index a3e9e92bc..82350cd8b 100644 --- a/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs @@ -37,7 +37,7 @@ protected override async Task CreateTicketAsync( [NotNull] AuthenticationProperties properties, [NotNull] OAuthTokenResponse tokens) { - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["access_token"] = tokens.AccessToken, ["uid"] = tokens.Response.RootElement.GetString("uid") diff --git a/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs index ddedd05ec..237ee8350 100644 --- a/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( [NotNull] AuthenticationProperties properties, [NotNull] OAuthTokenResponse tokens) { - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["access_token"] = tokens.AccessToken, ["openid"] = tokens.Response.RootElement.GetString("openid") @@ -99,7 +99,7 @@ protected override async Task CreateTicketAsync( protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) { - string address = QueryHelpers.AddQueryString(Options.TokenEndpoint, new Dictionary() + string address = QueryHelpers.AddQueryString(Options.TokenEndpoint, new Dictionary() { ["appid"] = Options.ClientId, ["secret"] = Options.ClientSecret, @@ -146,7 +146,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p addRedirectHash = true; } - redirectUri = QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary + redirectUri = QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, new Dictionary { ["appid"] = Options.ClientId, ["scope"] = FormatScope(), diff --git a/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs index 7485a60e3..34fa31bda 100644 --- a/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs @@ -36,7 +36,7 @@ protected override async Task CreateTicketAsync( [NotNull] OAuthTokenResponse tokens) { // See https://developers.zalo.me/docs/api/social-api/tai-lieu/thong-tin-nguoi-dung-post-28 - string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { ["access_token"] = tokens.AccessToken, ["fields"] = "id,name,birthday,gender" @@ -74,7 +74,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) { - string address = QueryHelpers.AddQueryString(Options.TokenEndpoint, new Dictionary + string address = QueryHelpers.AddQueryString(Options.TokenEndpoint, new Dictionary { ["app_id"] = Options.ClientId, ["app_secret"] = Options.ClientSecret, From 446e1e234026ad05221194bba022ed3b799da2ce Mon Sep 17 00:00:00 2001 From: martincostello Date: Wed, 26 Aug 2020 07:56:31 +0100 Subject: [PATCH 3/6] Update to ASP.NET 5 preview 8 Update to preview 8 of ASP.NET 5. --- Directory.Packages.props | 8 ++++---- global.json | 2 +- .../Mvc.Client/Controllers/AuthenticationController.cs | 2 +- .../VisualStudioAuthenticationDefaults.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index d34f785e2..08a1f727f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,10 +4,10 @@ - - - - + + + + diff --git a/global.json b/global.json index 1d48306fd..fedd27c73 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-preview.7.20366.6" + "dotnet": "5.0.100-preview.8.20417.9" }, "msbuild-sdks": { diff --git a/samples/Mvc.Client/Controllers/AuthenticationController.cs b/samples/Mvc.Client/Controllers/AuthenticationController.cs index 114775e90..69601a8d6 100644 --- a/samples/Mvc.Client/Controllers/AuthenticationController.cs +++ b/samples/Mvc.Client/Controllers/AuthenticationController.cs @@ -40,7 +40,7 @@ public async Task SignIn([FromForm] string provider) [HttpGet("~/signout")] [HttpPost("~/signout")] - public IActionResult SignOut() + public override SignOutResult SignOut() { // Instruct the cookies middleware to delete the local cookie created // when the user agent is redirected from the external identity provider diff --git a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs index 9b5053751..45925abf6 100644 --- a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs +++ b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs @@ -17,7 +17,7 @@ public static class VisualStudioAuthenticationDefaults /// /// Default value for . /// - public const string AuthenticationScheme = "Visual Studio Online"; + public const string AuthenticationScheme = "VisualStudioOnline"; /// /// Default value for . From 064688dde79542038bdae5b6a2d0a524a1122f53 Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 5 Sep 2020 15:33:38 +0100 Subject: [PATCH 4/6] Align with AspNetCore previews Update the version metadata to align with ASP.NET Core, so we generate prerelease labels like "preview.8." or "rc.1.". --- eng/Versions.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eng/Versions.props b/eng/Versions.props index bf9b601b2..686c6449c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -6,8 +6,12 @@ 0 $(MajorVersion).$(MinorVersion).$(PatchVersion) preview + 8 + Preview $(PreReleaseVersionIteration) false release + true + false From c6e6614fb57e12518be9d90157b9ae13aeeee1c1 Mon Sep 17 00:00:00 2001 From: martincostello Date: Mon, 14 Sep 2020 21:37:37 +0100 Subject: [PATCH 5/6] Update to ASP.NET 5 RC1 Update to RC1 of ASP.NET 5. --- Directory.Packages.props | 8 ++++---- eng/Versions.props | 6 +++--- global.json | 2 +- .../AmazonAuthenticationHandler.cs | 2 +- .../AppleAuthenticationHandler.cs | 8 ++++---- .../ArcGISAuthenticationHandler.cs | 2 +- .../AsanaAuthenticationHandler.cs | 2 +- .../AutodeskAuthenticationHandler.cs | 2 +- .../AutomaticAuthenticationHandler.cs | 2 +- .../BaiduAuthenticationHandler.cs | 2 +- .../BaiduAuthenticationOptions.cs | 2 +- .../BasecampAuthenticationHandler.cs | 2 +- .../BattleNetAuthenticationHandler.cs | 2 +- .../BeamAuthenticationHandler.cs | 2 +- .../BitbucketAuthenticationHandler.cs | 2 +- .../BufferAuthenticationHandler.cs | 2 +- .../CiscoSparkAuthenticationHandler.cs | 2 +- .../DeezerAuthenticationHandler.cs | 2 +- .../DeviantArtAuthenticationHandler.cs | 2 +- .../DiscordAuthenticationHandler.cs | 2 +- .../DropboxAuthenticationHandler.cs | 2 +- .../EVEOnlineAuthenticationHandler.cs | 2 +- .../ExactOnlineAuthenticationHandler.cs | 2 +- .../FitbitAuthenticationHandler.cs | 2 +- .../FoursquareAuthenticationHandler.cs | 2 +- .../GitHubAuthenticationHandler.cs | 2 +- .../GitLabAuthenticationHandler.cs | 2 +- .../GiteeAuthenticationHandler.cs | 2 +- .../GitterAuthenticationHandler.cs | 2 +- .../HarvestAuthenticationHandler.cs | 2 +- .../HealthGraphAuthenticationHandler.cs | 2 +- .../ImgurAuthenticationHandler.cs | 2 +- .../InstagramAuthenticationHandler.cs | 2 +- .../LinkedInAuthenticationHandler.cs | 2 +- .../LinkedInAuthenticationOptions.cs | 2 +- .../MailChimpAuthenticationHandler.cs | 2 +- .../MailRuAuthenticationHandler.cs | 2 +- .../MyobAuthenticationHandler.cs | 2 +- .../NetEaseAuthenticationHandler.cs | 2 +- .../NextcloudAuthenticationHandler.cs | 4 ++-- .../OdnoklassnikiAuthenticationHandler.cs | 2 +- .../OktaAuthenticationHandler.cs | 2 +- .../OnshapeAuthenticationHandler.cs | 2 +- .../PatreonAuthenticationHandler.cs | 2 +- .../PaypalAuthenticationHandler.cs | 2 +- .../QQAuthenticationHandler.cs | 4 ++-- .../RedditAuthenticationHandler.cs | 2 +- .../SalesforceAuthenticationHandler.cs | 2 +- .../ShopifyAuthenticationHandler.cs | 10 +++++----- .../SlackAuthenticationHandler.cs | 2 +- .../SoundCloudAuthenticationHandler.cs | 2 +- .../SpotifyAuthenticationHandler.cs | 2 +- .../StackExchangeAuthenticationHandler.cs | 2 +- .../StravaAuthenticationHandler.cs | 2 +- .../SuperOfficeAuthenticationHandler.cs | 8 ++++---- .../TraktAuthenticationHandler.cs | 2 +- .../TwitchAuthenticationHandler.cs | 2 +- .../UntappdAuthenticationHandler.cs | 2 +- .../VimeoAuthenticationHandler.cs | 2 +- .../VisualStudioAuthenticationDefaults.cs | 2 +- .../VisualStudioAuthenticationHandler.cs | 2 +- .../VkontakteAuthenticationHandler.cs | 2 +- .../WeiboAuthenticationHandler.cs | 2 +- .../WeixinAuthenticationHandler.cs | 2 +- .../WordPressAuthenticationHandler.cs | 2 +- .../YahooAuthenticationHandler.cs | 2 +- .../YammerAuthenticationHandler.cs | 6 +++--- .../YandexAuthenticationHandler.cs | 2 +- .../ZaloAuthenticationHandler.cs | 2 +- .../Infrastructure/ApplicationFactory.cs | 12 ++++++------ .../OAuthTests`1.cs | 10 +++++----- 71 files changed, 99 insertions(+), 99 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 08a1f727f..c2dca6cfa 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,10 +4,10 @@ - - - - + + + + diff --git a/eng/Versions.props b/eng/Versions.props index 686c6449c..aa505ed23 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -5,9 +5,9 @@ 0 0 $(MajorVersion).$(MinorVersion).$(PatchVersion) - preview - 8 - Preview $(PreReleaseVersionIteration) + rc + 1 + RC $(PreReleaseVersionIteration) false release true diff --git a/global.json b/global.json index fedd27c73..2bf4ea268 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-preview.8.20417.9" + "dotnet": "5.0.100-rc.1.20452.10" }, "msbuild-sdks": { diff --git a/src/AspNet.Security.OAuth.Amazon/AmazonAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Amazon/AmazonAuthenticationHandler.cs index 257438106..f80ae50a9 100644 --- a/src/AspNet.Security.OAuth.Amazon/AmazonAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Amazon/AmazonAuthenticationHandler.cs @@ -76,7 +76,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs index f3232b820..3d9c2466e 100644 --- a/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs @@ -80,7 +80,7 @@ protected override async Task CreateTicketAsync( [NotNull] AuthenticationProperties properties, [NotNull] OAuthTokenResponse tokens) { - string idToken = tokens.Response.RootElement.GetString("id_token"); + string? idToken = tokens.Response.RootElement.GetString("id_token"); Logger.LogInformation("Creating ticket for Sign in with Apple."); @@ -118,7 +118,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } /// @@ -170,8 +170,8 @@ protected virtual IEnumerable ExtractClaimsFromUser([NotNull] JsonElement if (user.TryGetProperty("name", out var name)) { - claims.Add(new Claim(ClaimTypes.GivenName, name.GetString("firstName"), ClaimValueTypes.String, ClaimsIssuer)); - claims.Add(new Claim(ClaimTypes.Surname, name.GetString("lastName"), ClaimValueTypes.String, ClaimsIssuer)); + claims.Add(new Claim(ClaimTypes.GivenName, name.GetString("firstName") ?? string.Empty, ClaimValueTypes.String, ClaimsIssuer)); + claims.Add(new Claim(ClaimTypes.Surname, name.GetString("lastName") ?? string.Empty, ClaimValueTypes.String, ClaimsIssuer)); } if (user.TryGetProperty("email", out var email)) diff --git a/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs b/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs index ac944cb41..09c174cf5 100644 --- a/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.ArcGIS/ArcGISAuthenticationHandler.cs @@ -68,7 +68,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Asana/AsanaAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Asana/AsanaAuthenticationHandler.cs index fbc910edb..0e1c47885 100644 --- a/src/AspNet.Security.OAuth.Asana/AsanaAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Asana/AsanaAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(payload.RootElement.GetProperty("data")); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Autodesk/AutodeskAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Autodesk/AutodeskAuthenticationHandler.cs index 5da87c0b1..441f86f8b 100644 --- a/src/AspNet.Security.OAuth.Autodesk/AutodeskAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Autodesk/AutodeskAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs index e516d9e64..1ffd9ad9c 100644 --- a/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Automatic/AutomaticAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override string BuildChallengeUrl([NotNull] AuthenticationProperties properties, [NotNull] string redirectUri) diff --git a/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationHandler.cs index f1a69c396..d17478d9b 100644 --- a/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationOptions.cs b/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationOptions.cs index 0d0e741f9..cfb059d1f 100644 --- a/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.Baidu/BaiduAuthenticationOptions.cs @@ -31,7 +31,7 @@ public BaiduAuthenticationOptions() ClaimActions.MapCustomJson(BaiduAuthenticationConstants.Claims.Portrait, user => { - string portrait = user.GetString("portrait"); + string? portrait = user.GetString("portrait"); return string.IsNullOrWhiteSpace(portrait) ? null : $"https://tb.himg.baidu.com/sys/portrait/item/{WebUtility.UrlEncode(portrait)}"; diff --git a/src/AspNet.Security.OAuth.Basecamp/BasecampAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Basecamp/BasecampAuthenticationHandler.cs index 03750ec9a..7e0761a05 100644 --- a/src/AspNet.Security.OAuth.Basecamp/BasecampAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Basecamp/BasecampAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.BattleNet/BattleNetAuthenticationHandler.cs b/src/AspNet.Security.OAuth.BattleNet/BattleNetAuthenticationHandler.cs index 2c9dc1c54..5141ad063 100644 --- a/src/AspNet.Security.OAuth.BattleNet/BattleNetAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.BattleNet/BattleNetAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Beam/BeamAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Beam/BeamAuthenticationHandler.cs index c81b79841..d6445bba9 100644 --- a/src/AspNet.Security.OAuth.Beam/BeamAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Beam/BeamAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs index 33ecea774..b0b0e6d1a 100644 --- a/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Bitbucket/BitbucketAuthenticationHandler.cs @@ -72,7 +72,7 @@ protected override async Task CreateTicketAsync( } await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) diff --git a/src/AspNet.Security.OAuth.Buffer/BufferAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Buffer/BufferAuthenticationHandler.cs index 213c8c73f..8d1c8f051 100644 --- a/src/AspNet.Security.OAuth.Buffer/BufferAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Buffer/BufferAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.CiscoSpark/CiscoSparkAuthenticationHandler.cs b/src/AspNet.Security.OAuth.CiscoSpark/CiscoSparkAuthenticationHandler.cs index 459d5620f..39aef57e2 100644 --- a/src/AspNet.Security.OAuth.CiscoSpark/CiscoSparkAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.CiscoSpark/CiscoSparkAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs index 522b88e73..a52a4aa31 100644 --- a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs @@ -104,7 +104,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override string BuildChallengeUrl([NotNull] AuthenticationProperties properties, [NotNull] string redirectUri) diff --git a/src/AspNet.Security.OAuth.DeviantArt/DeviantArtAuthenticationHandler.cs b/src/AspNet.Security.OAuth.DeviantArt/DeviantArtAuthenticationHandler.cs index e3c951068..6d54d8815 100644 --- a/src/AspNet.Security.OAuth.DeviantArt/DeviantArtAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.DeviantArt/DeviantArtAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Discord/DiscordAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Discord/DiscordAuthenticationHandler.cs index 0beb30084..0c34dd539 100644 --- a/src/AspNet.Security.OAuth.Discord/DiscordAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Discord/DiscordAuthenticationHandler.cs @@ -74,7 +74,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Dropbox/DropboxAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Dropbox/DropboxAuthenticationHandler.cs index e33c14a40..a85e2fb48 100644 --- a/src/AspNet.Security.OAuth.Dropbox/DropboxAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Dropbox/DropboxAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.EVEOnline/EVEOnlineAuthenticationHandler.cs b/src/AspNet.Security.OAuth.EVEOnline/EVEOnlineAuthenticationHandler.cs index b6885a600..4b4309cda 100644 --- a/src/AspNet.Security.OAuth.EVEOnline/EVEOnlineAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.EVEOnline/EVEOnlineAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.ExactOnline/ExactOnlineAuthenticationHandler.cs b/src/AspNet.Security.OAuth.ExactOnline/ExactOnlineAuthenticationHandler.cs index 19678ca2a..fc1485f38 100755 --- a/src/AspNet.Security.OAuth.ExactOnline/ExactOnlineAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.ExactOnline/ExactOnlineAuthenticationHandler.cs @@ -64,7 +64,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(user); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs index d88877c01..f6a2b93ec 100644 --- a/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Fitbit/FitbitAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(payload.RootElement.GetProperty("user")); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) diff --git a/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs index c2c7145fd..16f3e242d 100644 --- a/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Foursquare/FoursquareAuthenticationHandler.cs @@ -73,7 +73,7 @@ protected override async Task CreateTicketAsync( } await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs b/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs index 675def569..c02869ea4 100644 --- a/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.GitHub/GitHubAuthenticationHandler.cs @@ -72,7 +72,7 @@ protected override async Task CreateTicketAsync( } await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) diff --git a/src/AspNet.Security.OAuth.GitLab/GitLabAuthenticationHandler.cs b/src/AspNet.Security.OAuth.GitLab/GitLabAuthenticationHandler.cs index 2a2a416ab..84737cde8 100644 --- a/src/AspNet.Security.OAuth.GitLab/GitLabAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.GitLab/GitLabAuthenticationHandler.cs @@ -58,7 +58,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs index de5263d41..67f254e5b 100644 --- a/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Gitee/GiteeAuthenticationHandler.cs @@ -72,7 +72,7 @@ protected override async Task CreateTicketAsync( } await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) diff --git a/src/AspNet.Security.OAuth.Gitter/GitterAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Gitter/GitterAuthenticationHandler.cs index 4eff33885..7b8f90c71 100644 --- a/src/AspNet.Security.OAuth.Gitter/GitterAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Gitter/GitterAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Harvest/HarvestAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Harvest/HarvestAuthenticationHandler.cs index 6f5b64faf..c67016785 100644 --- a/src/AspNet.Security.OAuth.Harvest/HarvestAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Harvest/HarvestAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.HealthGraph/HealthGraphAuthenticationHandler.cs b/src/AspNet.Security.OAuth.HealthGraph/HealthGraphAuthenticationHandler.cs index 2bb41360d..91dd38c94 100644 --- a/src/AspNet.Security.OAuth.HealthGraph/HealthGraphAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.HealthGraph/HealthGraphAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Imgur/ImgurAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Imgur/ImgurAuthenticationHandler.cs index 24ba002ef..26e638303 100644 --- a/src/AspNet.Security.OAuth.Imgur/ImgurAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Imgur/ImgurAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(payload.RootElement.GetProperty("data")); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs index 141dc2164..c7672617d 100644 --- a/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Instagram/InstagramAuthenticationHandler.cs @@ -65,7 +65,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationHandler.cs b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationHandler.cs index bb0551787..f84783407 100644 --- a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationHandler.cs @@ -81,7 +81,7 @@ protected override async Task CreateTicketAsync( } await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected virtual async Task GetEmailAsync([NotNull] OAuthTokenResponse tokens) diff --git a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs index 141ffbe99..fda97b75d 100644 --- a/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.LinkedIn/LinkedInAuthenticationOptions.cs @@ -140,7 +140,7 @@ private static IEnumerable GetPictureUrls(JsonElement user) continue; } - string pictureUrl = imageIdentifier + string? pictureUrl = imageIdentifier .EnumerateArray() .FirstOrDefault() .GetString("identifier"); diff --git a/src/AspNet.Security.OAuth.MailChimp/MailChimpAuthenticationHandler.cs b/src/AspNet.Security.OAuth.MailChimp/MailChimpAuthenticationHandler.cs index 282dd39cf..f62adc3d5 100644 --- a/src/AspNet.Security.OAuth.MailChimp/MailChimpAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.MailChimp/MailChimpAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.MailRu/MailRuAuthenticationHandler.cs b/src/AspNet.Security.OAuth.MailRu/MailRuAuthenticationHandler.cs index a120c1600..f951e18ff 100644 --- a/src/AspNet.Security.OAuth.MailRu/MailRuAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.MailRu/MailRuAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Myob/MyobAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Myob/MyobAuthenticationHandler.cs index bb6f31191..15b8606a5 100644 --- a/src/AspNet.Security.OAuth.Myob/MyobAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Myob/MyobAuthenticationHandler.cs @@ -40,7 +40,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.NetEase/NetEaseAuthenticationHandler.cs b/src/AspNet.Security.OAuth.NetEase/NetEaseAuthenticationHandler.cs index 4c91cae59..4e4b650d7 100644 --- a/src/AspNet.Security.OAuth.NetEase/NetEaseAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.NetEase/NetEaseAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Nextcloud/NextcloudAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Nextcloud/NextcloudAuthenticationHandler.cs index c46c9abee..5e15086d9 100644 --- a/src/AspNet.Security.OAuth.Nextcloud/NextcloudAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Nextcloud/NextcloudAuthenticationHandler.cs @@ -35,7 +35,7 @@ protected override async Task CreateTicketAsync( [NotNull] AuthenticationProperties properties, [NotNull] OAuthTokenResponse tokens) { - string userId = tokens.Response.RootElement.GetString("user_id"); + string userId = tokens.Response.RootElement.GetString("user_id") ?? string.Empty; string userEndpoint = Options.UserInformationEndpoint.TrimEnd('/'); userEndpoint += $"/{Uri.EscapeUriString(userId)}"; @@ -62,7 +62,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs index 1c326b902..49cc3c45f 100644 --- a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs @@ -74,7 +74,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } private static string GetHash(HashAlgorithm algorithm, string input) diff --git a/src/AspNet.Security.OAuth.Okta/OktaAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Okta/OktaAuthenticationHandler.cs index 0aba1f72e..f57087847 100644 --- a/src/AspNet.Security.OAuth.Okta/OktaAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Okta/OktaAuthenticationHandler.cs @@ -70,7 +70,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Onshape/OnshapeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Onshape/OnshapeAuthenticationHandler.cs index da241e5dd..b30a30e87 100644 --- a/src/AspNet.Security.OAuth.Onshape/OnshapeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Onshape/OnshapeAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Patreon/PatreonAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Patreon/PatreonAuthenticationHandler.cs index 110469ba8..7c3406d28 100644 --- a/src/AspNet.Security.OAuth.Patreon/PatreonAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Patreon/PatreonAuthenticationHandler.cs @@ -70,7 +70,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(payload.RootElement.GetProperty("data")); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Paypal/PaypalAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Paypal/PaypalAuthenticationHandler.cs index 4ceeee753..67982ee8d 100644 --- a/src/AspNet.Security.OAuth.Paypal/PaypalAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Paypal/PaypalAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs b/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs index 93000b905..bdd444ee2 100644 --- a/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.QQ/QQAuthenticationHandler.cs @@ -83,7 +83,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) @@ -144,7 +144,7 @@ private async Task GetUserIdentifierAsync(OAuthTokenResponse tokens) using var payload = JsonDocument.Parse(body); - return payload.RootElement.GetString("openid"); + return payload.RootElement.GetString("openid") ?? string.Empty; } protected override string FormatScope() => string.Join(",", Options.Scope); diff --git a/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs index 0db09076e..957fbb2c7 100644 --- a/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Reddit/RedditAuthenticationHandler.cs @@ -68,7 +68,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override string BuildChallengeUrl([NotNull] AuthenticationProperties properties, [NotNull] string redirectUri) diff --git a/src/AspNet.Security.OAuth.Salesforce/SalesforceAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Salesforce/SalesforceAuthenticationHandler.cs index 8b9e02763..16f6986a1 100644 --- a/src/AspNet.Security.OAuth.Salesforce/SalesforceAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Salesforce/SalesforceAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs index 2256559c7..9032fdb69 100644 --- a/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Shopify/ShopifyAuthenticationHandler.cs @@ -61,7 +61,7 @@ protected override async Task CreateTicketAsync( // In Shopify, the customer can modify the scope given to the app. Apps should verify // that the customer is allowing the required scope. - string actualScope = tokens.Response.RootElement.GetString("scope"); + string actualScope = tokens.Response.RootElement.GetString("scope") ?? string.Empty; bool isPersistent = true; // If the request was for a "per-user" (i.e. no offline access) @@ -75,9 +75,9 @@ protected override async Task CreateTicketAsync( identity.AddClaim(new Claim(ClaimTypes.Expiration, expires.ToString("O", CultureInfo.InvariantCulture), ClaimValueTypes.DateTime)); } - actualScope = tokens.Response.RootElement.GetString("associated_user_scope"); + actualScope = tokens.Response.RootElement.GetString("associated_user_scope") ?? string.Empty; - string userData = tokens.Response.RootElement.GetString("associated_user"); + string userData = tokens.Response.RootElement.GetString("associated_user") ?? string.Empty; identity.AddClaim(new Claim(ClaimTypes.UserData, userData)); } @@ -89,7 +89,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } /// @@ -161,7 +161,7 @@ protected override async Task ExchangeCodeAsync([NotNull] OA // request the token. This probably isn't necessary, but it's an easy extra verification. var authenticationProperties = Options.StateDataFormat.Unprotect(stateValue); - string? shopNamePropertyValue = authenticationProperties.Items[ShopifyAuthenticationDefaults.ShopNameAuthenticationProperty]; + string? shopNamePropertyValue = authenticationProperties?.Items[ShopifyAuthenticationDefaults.ShopNameAuthenticationProperty]; if (!string.Equals(shopNamePropertyValue, shopDns, StringComparison.OrdinalIgnoreCase)) { diff --git a/src/AspNet.Security.OAuth.Slack/SlackAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Slack/SlackAuthenticationHandler.cs index 9e933de04..89541ade7 100644 --- a/src/AspNet.Security.OAuth.Slack/SlackAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Slack/SlackAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.SoundCloud/SoundCloudAuthenticationHandler.cs b/src/AspNet.Security.OAuth.SoundCloud/SoundCloudAuthenticationHandler.cs index d876114fa..0dd62f2b9 100644 --- a/src/AspNet.Security.OAuth.SoundCloud/SoundCloudAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.SoundCloud/SoundCloudAuthenticationHandler.cs @@ -59,7 +59,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Spotify/SpotifyAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Spotify/SpotifyAuthenticationHandler.cs index 943407d24..c7101eeba 100644 --- a/src/AspNet.Security.OAuth.Spotify/SpotifyAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Spotify/SpotifyAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs index 7902d03e5..eb3caa79e 100644 --- a/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.StackExchange/StackExchangeAuthenticationHandler.cs @@ -81,7 +81,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(payload.RootElement.GetProperty("items").EnumerateArray().First()); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) diff --git a/src/AspNet.Security.OAuth.Strava/StravaAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Strava/StravaAuthenticationHandler.cs index 92f9a3a07..de2f03d17 100644 --- a/src/AspNet.Security.OAuth.Strava/StravaAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Strava/StravaAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override string FormatScope() => string.Join(",", Options.Scope); diff --git a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs index 943e87a7c..253deb867 100644 --- a/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.SuperOffice/SuperOfficeAuthenticationHandler.cs @@ -78,7 +78,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } private async Task ProcessIdTokenAndGetContactIdentifierAsync( @@ -86,7 +86,7 @@ private async Task ProcessIdTokenAndGetContactIdentifierAsync( [NotNull] AuthenticationProperties properties, [NotNull] ClaimsIdentity identity) { - var idToken = tokens.Response.RootElement.GetString("id_token"); + string? idToken = tokens.Response.RootElement.GetString("id_token"); if (Options.SaveTokens) { @@ -131,7 +131,7 @@ private async Task ProcessIdTokenAndGetContactIdentifierAsync( /// The id_token JWT. private static void SaveIdToken( [NotNull] AuthenticationProperties properties, - [NotNull] string idToken) + [NotNull] string? idToken) { if (!string.IsNullOrWhiteSpace(idToken)) { @@ -147,7 +147,7 @@ private static void SaveIdToken( } private async Task ValidateAsync( - [NotNull] string idToken, + [NotNull] string? idToken, [NotNull] TokenValidationParameters validationParameters) { if (Options.SecurityTokenHandler == null) diff --git a/src/AspNet.Security.OAuth.Trakt/TraktAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Trakt/TraktAuthenticationHandler.cs index 2dd373f8b..52294bae1 100644 --- a/src/AspNet.Security.OAuth.Trakt/TraktAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Trakt/TraktAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs index c46226a1d..726585677 100644 --- a/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs @@ -71,7 +71,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Untappd/UntappdAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Untappd/UntappdAuthenticationHandler.cs index 016dbe5f5..72329f02a 100644 --- a/src/AspNet.Security.OAuth.Untappd/UntappdAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Untappd/UntappdAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(payload.RootElement.GetProperty("user")); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Vimeo/VimeoAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Vimeo/VimeoAuthenticationHandler.cs index 83f152445..c21a778e1 100644 --- a/src/AspNet.Security.OAuth.Vimeo/VimeoAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Vimeo/VimeoAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs index 45925abf6..9b5053751 100644 --- a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs +++ b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationDefaults.cs @@ -17,7 +17,7 @@ public static class VisualStudioAuthenticationDefaults /// /// Default value for . /// - public const string AuthenticationScheme = "VisualStudioOnline"; + public const string AuthenticationScheme = "Visual Studio Online"; /// /// Default value for . diff --git a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs index 1e366b708..bdaa47bf0 100644 --- a/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.VisualStudio/VisualStudioAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) diff --git a/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs index 62fc62423..2d2fe01c2 100644 --- a/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Vkontakte/VkontakteAuthenticationHandler.cs @@ -71,7 +71,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(tokens.Response.RootElement); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs index 82350cd8b..acf565df6 100644 --- a/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Weibo/WeiboAuthenticationHandler.cs @@ -79,7 +79,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override string FormatScope() => string.Join(",", Options.Scope); diff --git a/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs index 237ee8350..c50aa1d67 100644 --- a/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Weixin/WeixinAuthenticationHandler.cs @@ -94,7 +94,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) diff --git a/src/AspNet.Security.OAuth.WordPress/WordPressAuthenticationHandler.cs b/src/AspNet.Security.OAuth.WordPress/WordPressAuthenticationHandler.cs index 49e719f66..8af5d5eed 100644 --- a/src/AspNet.Security.OAuth.WordPress/WordPressAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.WordPress/WordPressAuthenticationHandler.cs @@ -57,7 +57,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } } } diff --git a/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs index e1a0847e4..6716b5a9d 100644 --- a/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Yahoo/YahooAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(payload.RootElement); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) diff --git a/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs index c682a3238..51fddff6d 100644 --- a/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) @@ -95,13 +95,13 @@ protected override async Task ExchangeCodeAsync([NotNull] OA // with the OAuth2 generic middleware, a compliant JSON payload is generated manually. // See https://developer.yammer.com/docs/oauth-2 for more information about this process. using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync()); - string accessToken = payload.RootElement.GetProperty("access_token").GetString("token"); + string? accessToken = payload.RootElement.GetProperty("access_token").GetString("token"); var token = await CreateAccessTokenAsync(accessToken); return OAuthTokenResponse.Success(token); } - private static async Task CreateAccessTokenAsync(string accessToken) + private static async Task CreateAccessTokenAsync(string? accessToken) { var bufferWriter = new ArrayBufferWriter(); diff --git a/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs index 2c3508cfc..286c1db79 100644 --- a/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Yandex/YandexAuthenticationHandler.cs @@ -60,7 +60,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override async Task ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) diff --git a/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs index 34fa31bda..f7dbb99c2 100644 --- a/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Zalo/ZaloAuthenticationHandler.cs @@ -63,7 +63,7 @@ protected override async Task CreateTicketAsync( context.RunClaimActions(); await Options.Events.CreatingTicket(context); - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } protected override string BuildChallengeUrl([NotNull] AuthenticationProperties properties, [NotNull] string redirectUri) diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs b/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs index bbc7ec0ef..26b6698b1 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Infrastructure/ApplicationFactory.cs @@ -122,18 +122,18 @@ private static void ConfigureApplication(IApplicationBuilder app, OAut private static string IdentityToXmlString(ClaimsPrincipal user) { - var element = new XElement("claims"); + var element = new XElement("claims"!); foreach (var identity in user.Identities) { foreach (var claim in identity.Claims) { var node = new XElement( - "claim", - new XAttribute("type", claim.Type), - new XAttribute("value", claim.Value), - new XAttribute("valueType", claim.ValueType), - new XAttribute("issuer", claim.Issuer)); + "claim"!, + new XAttribute("type"!, claim.Type), + new XAttribute("value"!, claim.Value), + new XAttribute("valueType"!, claim.ValueType), + new XAttribute("issuer"!, claim.Issuer)); element.Add(node); } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs b/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs index aa9bbe6ee..d5cb03900 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/OAuthTests`1.cs @@ -212,7 +212,7 @@ protected async Task> AuthenticateUserAsync(WebApplic element = XElement.Parse(xml); } - element.Name.ShouldBe("claims"); + element.Name!.ShouldBe("claims"!); element.Elements("claim").Count().ShouldBeGreaterThanOrEqualTo(1); var claims = new List(); @@ -221,10 +221,10 @@ protected async Task> AuthenticateUserAsync(WebApplic { claims.Add( new Claim( - claim.Attribute("type").Value, - claim.Attribute("value").Value, - claim.Attribute("valueType").Value, - claim.Attribute("issuer").Value)); + claim.Attribute("type"!) !.Value, + claim.Attribute("value"!) !.Value, + claim.Attribute("valueType"!) !.Value, + claim.Attribute("issuer"!) !.Value)); } return claims.ToDictionary((key) => key.Type, (value) => value); From 51986ab3d5082d3f2c8adf2197ce92211e4f5771 Mon Sep 17 00:00:00 2001 From: martincostello Date: Mon, 14 Sep 2020 21:47:45 +0100 Subject: [PATCH 6/6] Use HashData() and ToHexString() methods Use new HashData() methods for SHA256 and MD5. Use Convert.ToHexString(). --- .../DeezerAuthenticationHandler.cs | 3 +-- .../OdnoklassnikiAuthenticationHandler.cs | 20 ++++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs index a52a4aa31..1d00e3c7e 100644 --- a/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Deezer/DeezerAuthenticationHandler.cs @@ -128,8 +128,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p // Store this for use during the code redemption. properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier); - using var sha256 = HashAlgorithm.Create("SHA256"); - byte[] challengeBytes = sha256!.ComputeHash(Encoding.UTF8.GetBytes(codeVerifier)); + byte[] challengeBytes = SHA256.HashData(Encoding.UTF8.GetBytes(codeVerifier)); parameters[OAuthConstants.CodeChallengeKey] = WebEncoders.Base64UrlEncode(challengeBytes); parameters[OAuthConstants.CodeChallengeMethodKey] = OAuthConstants.CodeChallengeMethodS256; } diff --git a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs index 49cc3c45f..7adb14d7e 100644 --- a/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Odnoklassniki/OdnoklassnikiAuthenticationHandler.cs @@ -4,8 +4,8 @@ * for more information concerning the license and the contributors participating to this project. */ +using System; using System.Collections.Generic; -using System.Globalization; using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; @@ -39,9 +39,8 @@ protected override async Task CreateTicketAsync( [NotNull] AuthenticationProperties properties, [NotNull] OAuthTokenResponse tokens) { - using var algorithm = HashAlgorithm.Create("MD5"); - string accessSecret = GetHash(algorithm!, tokens.AccessToken + Options.ClientSecret); - string sign = GetHash(algorithm!, $"application_key={Options.PublicSecret}format=jsonmethod=users.getCurrentUser{accessSecret}"); + string accessSecret = GetMD5Hash(tokens.AccessToken + Options.ClientSecret); + string sign = GetMD5Hash($"application_key={Options.PublicSecret}format=jsonmethod=users.getCurrentUser{accessSecret}"); string address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary { @@ -77,16 +76,13 @@ protected override async Task CreateTicketAsync( return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); } - private static string GetHash(HashAlgorithm algorithm, string input) + private static string GetMD5Hash(string input) { - var builder = new StringBuilder(); +#pragma warning disable CA5351 + byte[] hash = MD5.HashData(Encoding.UTF8.GetBytes(input)); +#pragma warning restore CA5351 - foreach (byte b in algorithm.ComputeHash(Encoding.UTF8.GetBytes(input))) - { - builder.Append(b.ToString("x2", CultureInfo.InvariantCulture)); - } - - return builder.ToString(); + return Convert.ToHexString(hash).ToLowerInvariant(); } } }