lvermeulen / Keycloak.Net

C# client for Keycloak 6.x
MIT License
203 stars 120 forks source link

Protocol Mapper Issue #60

Open josuelopez-oceanscode opened 3 years ago

josuelopez-oceanscode commented 3 years ago

When working with the protocol mappers I encounter a severe bug in the JSON implementation. This class Keycloak.Net.Models.ProtocolMappers.Config should be changed to Dictionary<string,object> Per the docs https://www.keycloak.org/docs-api/5.0/rest-api/index.html#_protocolmapperrepresentation this attribute it's type map meaning that there's not defined structure so a named based structure like the one you have is not working and will not retrieve all the information. please change it to Dictionary class: see also https://docs.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonextensiondataattribute?view=net-5.0 https://stackoverflow.com/questions/14893614/how-to-serialize-a-dictionary-as-part-of-its-parent-object-using-json-net

josuelopez-oceanscode commented 3 years ago

Suggested change:

Keycloak.Net.Models.ProtocolMappers.ProtocolMapper [JsonProperty("config")] public Config Config { get; set; }

should be replaced to: [JsonProperty("config"), JsonExtensionData] public Dictionary<string, object> Config { get; set; }

AnderssonPeter commented 2 years ago

I have created a new nuget package that has this fix https://www.nuget.org/packages/Keycloak.Net.Core/