Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Announcement] Newtonsoft.Json types replaced in Microsoft.AspNetCore.Authentication APIs #7289

Closed
Tratcher opened this issue Feb 5, 2019 · 1 comment
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer breaking-change This issue / pr will introduce a breaking change, when resolved / merged.
Milestone

Comments

@Tratcher
Copy link
Member

Tratcher commented Feb 5, 2019

As part of the ongoing effort to remove Newtonsoft.Json from the shared framework these types have now been replaced on the Authentication APIs.

Basic usage of these Authentication packages should be unaffected. Only users who have derived from the OAuth package or that had implemented advanced claim manipulation should be affected. A detailed list of affected APIs is given below.

Affected packages:

  • Microsoft.AspNetCore.Authentication.OAuth
  • Microsoft.AspNetCore.Authentication.OpenIdConnect
  • Microsoft.AspNetCore.Authentication.Facebook
  • Microsoft.AspNetCore.Authentication.Google
  • Microsoft.AspNetCore.Authentication.Twitter
  • Microsoft.AspNetCore.Authentication.MicrosoftAccount

Also, all derived implementations of OAuth such as those from aspnet-contrib.

For derived OAuth implementations the most common change is to replace JObject.Parse with JsonDocument.Parse in the CreateTicketAsync override as shown here. Note JsonDocument is IDisposable.

Affected APIs:

  • ClaimAction.Run(JObject userData, ClaimsIdentity identity, string issuer) becomes ClaimAction.Run(JsonElement userData, ClaimsIdentity identity, string issuer). All derived implementations of ClaimAction are similarly affected.
  • MapCustomJson(this ClaimActionCollection collection, string claimType, Func<JObject, string> resolver) becomes MapCustomJson(this ClaimActionCollection collection, string claimType, Func<JsonElement, string> resolver)
  • MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func<JObject, string> resolver) becomes MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func<JsonElement, string> resolver)
  • OAuthCreatingTicketContext has had one old constructor removed and the other replaced JObject with JsonElement. The User property and RunClaimActions method have been updated to match.
  • OAuthTokenResponse.Success now takes a JsonDocument instead of JObject. The Response property has been updated to match. OAuthTokenResponse is now disposable and will be disposed by OAuthHandler. Derived OAuth implementations overriding ExchangeCodeAsync do not need to dispose of the JsonDocument or OAuthTokenResponse.
  • UserInformationReceivedContext.User changed from JObject to JsonDocument.
  • TwitterCreatingTicketContext.User changed from JObject to JsonElement.
  • TwitterHandler.CreateTicketAsync changed from taking JObject to JsonElement.

See #7105 for details of the change.

@Tratcher Tratcher added discussion breaking-change This issue / pr will introduce a breaking change, when resolved / merged. area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer labels Feb 5, 2019
@Tratcher Tratcher added this to the 3.0.0-preview3 milestone Feb 5, 2019
@Eilon Eilon modified the milestones: 3.0.0-preview3, Discussions Feb 5, 2019
@aspnet-hello
Copy link

We periodically close 'discussion' issues that have not been updated in a long period of time.

We apologize if this causes any inconvenience. We ask that if you are still encountering an issue, please log a new issue with updated information and we will investigate.

@dotnet dotnet locked and limited conversation to collaborators Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer breaking-change This issue / pr will introduce a breaking change, when resolved / merged.
Projects
None yet
Development

No branches or pull requests

3 participants