Keycloak.Net icon indicating copy to clipboard operation
Keycloak.Net copied to clipboard

Protocol Mapper Issue

Open josuelopez-oceanscode opened this issue 2 years ago • 2 comments

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 avatar Aug 03 '21 05:08 josuelopez-oceanscode

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; }

josuelopez-oceanscode avatar Aug 03 '21 05:08 josuelopez-oceanscode

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

AnderssonPeter avatar Mar 22 '22 07:03 AnderssonPeter