diff --git a/eng/Versions.props b/eng/Versions.props index a457eded..54c51e51 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,6 +13,7 @@ 3.1.2 5.6.0 2019.1.3 + 10.0.3 3.0.0 0.1.0 3.0.2 diff --git a/src/AspNet.Security.OpenId.Steam/SteamAuthenticationHandler.cs b/src/AspNet.Security.OpenId.Steam/SteamAuthenticationHandler.cs index a4c48e00..4f5dd1a5 100644 --- a/src/AspNet.Security.OpenId.Steam/SteamAuthenticationHandler.cs +++ b/src/AspNet.Security.OpenId.Steam/SteamAuthenticationHandler.cs @@ -18,6 +18,7 @@ using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Newtonsoft.Json.Linq; namespace AspNet.Security.OpenId.Steam { @@ -100,10 +101,11 @@ protected override async Task CreateTicketAsync( using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync()); // Try to extract the profile name of the authenticated user. - var profile = payload.RootElement.GetProperty(SteamAuthenticationConstants.Parameters.Response) - .GetProperty(SteamAuthenticationConstants.Parameters.Players) - .EnumerateArray() - .FirstOrDefault(); + var profile = payload.RootElement + .GetProperty(SteamAuthenticationConstants.Parameters.Response) + .GetProperty(SteamAuthenticationConstants.Parameters.Players) + .EnumerateArray() + .FirstOrDefault(); if (profile.ValueKind == JsonValueKind.Object && profile.TryGetProperty(SteamAuthenticationConstants.Parameters.Name, out var name)) { @@ -116,9 +118,16 @@ async Task RunAuthenticatedEventAsync(JsonDocument user = { var context = new OpenIdAuthenticatedContext(Context, Scheme, Options, ticket) { - User = user + UserPayload = user }; + if (user != null) + { +#pragma warning disable CS0618 + context.User = JObject.Parse(user.RootElement.ToString()); +#pragma warning restore CS0618 + } + // Copy the attributes to the context object. foreach (var attribute in attributes) { diff --git a/src/AspNet.Security.OpenId/AspNet.Security.OpenId.csproj b/src/AspNet.Security.OpenId/AspNet.Security.OpenId.csproj index e20e00e6..822935c6 100644 --- a/src/AspNet.Security.OpenId/AspNet.Security.OpenId.csproj +++ b/src/AspNet.Security.OpenId/AspNet.Security.OpenId.csproj @@ -15,6 +15,7 @@ + diff --git a/src/AspNet.Security.OpenId/Events/OpenIdAuthenticatedContext.cs b/src/AspNet.Security.OpenId/Events/OpenIdAuthenticatedContext.cs index 117fb9c9..10019169 100644 --- a/src/AspNet.Security.OpenId/Events/OpenIdAuthenticatedContext.cs +++ b/src/AspNet.Security.OpenId/Events/OpenIdAuthenticatedContext.cs @@ -4,12 +4,14 @@ * for more information concerning the license and the contributors participating to this project. */ +using System; using System.Collections.Generic; using System.Security.Claims; using System.Text.Json; using JetBrains.Annotations; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; +using Newtonsoft.Json.Linq; namespace AspNet.Security.OpenId { @@ -57,6 +59,13 @@ public OpenIdAuthenticatedContext( /// Gets or sets the optional JSON payload extracted from the current request. /// This property is not set by the generic middleware but can be used by specialized middleware. /// - public JsonDocument User { get; set; } + [Obsolete("Use the UserPayload property instead. This property's type will change from JObject to JsonDocument in a future release.")] + public JObject User { get; set; } = new JObject(); + + /// + /// Gets or sets the optional JSON payload extracted from the current request. + /// This property is not set by the generic middleware but can be used by specialized middleware. + /// + public JsonDocument UserPayload { get; set; } } }