Fix/in browser postman auth & editor config boolean serialization (#14739)
* Add in-browser postman callback url * Added a jsonconverter for property editor configuration boolean values that are persisted as numbers and serialized as strings... --------- Co-authored-by: Sven Geusens <sge@umbraco.dk>
This commit is contained in:
@@ -97,7 +97,7 @@ public class BackOfficeApplicationManager : IBackOfficeApplicationManager
|
||||
ClientId = Constants.OauthClientIds.Postman,
|
||||
RedirectUris =
|
||||
{
|
||||
new Uri("https://oauth.pstmn.io/v1/callback")
|
||||
new Uri("https://oauth.pstmn.io/v1/callback"), new Uri("https://oauth.pstmn.io/v1/browser-callback")
|
||||
},
|
||||
Type = OpenIddictConstants.ClientTypes.Public,
|
||||
Permissions =
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Serialization;
|
||||
|
||||
public class JsonBoolConverter : JsonConverter<bool>
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) =>
|
||||
writer.WriteBooleanValue(value);
|
||||
|
||||
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.True => true,
|
||||
JsonTokenType.False => false,
|
||||
JsonTokenType.String => ParseString(ref reader),
|
||||
JsonTokenType.Number => reader.TryGetInt64(out long l) ? Convert.ToBoolean(l) : reader.TryGetDouble(out double d) ? Convert.ToBoolean(d) : false,
|
||||
_ => throw new JsonException(),
|
||||
};
|
||||
|
||||
private bool ParseString(ref Utf8JsonReader reader)
|
||||
{
|
||||
var value = reader.GetString();
|
||||
if (bool.TryParse(value, out var b))
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
if (int.TryParse(value, out var i))
|
||||
{
|
||||
return Convert.ToBoolean(i);
|
||||
}
|
||||
|
||||
throw new JsonException();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public class SystemTextConfigurationEditorJsonSerializer : IConfigurationEditorJ
|
||||
_jsonSerializerOptions.Converters.Add(new JsonObjectConverter());
|
||||
_jsonSerializerOptions.Converters.Add(new JsonUdiConverter());
|
||||
_jsonSerializerOptions.Converters.Add(new JsonGuidUdiConverter());
|
||||
_jsonSerializerOptions.Converters.Add(new JsonBoolConverter());
|
||||
}
|
||||
|
||||
public string Serialize(object? input) => JsonSerializer.Serialize(input, _jsonSerializerOptions);
|
||||
|
||||
Reference in New Issue
Block a user