lvermeulen/Keycloak.Net

Parsing client ProtocolMapper.Config is broken? (keycloak 15)

Closed this issue · 7 comments

When i request information about a client using client.GetClientsAsync(realm, clientId) i get back multiple Client instances, if i then drill down into one and access one ProtocolMappers, and check the Config everything is null.
image

I have done a manual request and then i get the following json response:

{
  "id": "5a0a5ecd-ac69-49ef-8d98-2da9a0a11ba3",
  "name": "Customer ID",
  "protocol": "openid-connect",
  "protocolMapper": "oidc-hardcoded-claim-mapper",
  "consentRequired": false,
  "config": {
    "claim.value": "test",
    "userinfo.token.claim": "false",
    "id.token.claim": "false",
    "access.token.claim": "true",
    "claim.name": "customer_id",
    "jsonType.label": "String",
    "access.tokenResponse.claim": "false"
  }
}

Does this package support keycloak 15 or is it stuck at 6?

After looking into it it seems https://github.com/lvermeulen/Keycloak.Net/blob/main/src/Keycloak.Net/Models/Clients/ClientConfig.cs has invalid JsonProperty values.
Also value (claim.value) seems to be missing entirely.

The question is, have the property names changed between versions or is this just a bug?

@lvermeulen i can make a PR if you would accept it?

I'm not that good with java but if i check the following file

v6: https://github.com/keycloak/keycloak/blob/6.0.0/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAttributeMapperHelper.java
v15: https://github.com/keycloak/keycloak/blob/15.0.2/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAttributeMapperHelper.java

They have the same string values but I'm not 100% sure that those are the values that are used for ClientConfig.

Sadly the documentation only says "map" so its somewhat hard to find the correct property names that way.
https://www.keycloak.org/docs-api/15.0/rest-api/index.html#_protocolmapperrepresentation

I see 2 solutions to this

  • Change from ClientConfig to a Dictionary<string, string>, this would be a breaking change but would fetch all the fields and seems most in sync with the documentation
  • Update the JsonProperty attributes

@lvermeulen Is this project still maintained?

@AnderssonPeter Has a lot been broken? I am planning to use this library with keycloak 17...

@adhip94 I don't know the above issue was a showstopper for me so i haven't used it..

But i guess a fork might be a way forward as @lvermeulen doesn't even answer...

I have created a fork that contains a fix for this, I have also taken the pull request for CancellationTokens.
But I haven't created a nuget package yet as I don't know what to call it.

https://github.com/AnderssonPeter/Keycloak.Net