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

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

Open AnderssonPeter opened this issue 2 years ago • 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?

AnderssonPeter avatar Nov 23 '21 10:11 AnderssonPeter

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?

AnderssonPeter avatar Nov 23 '21 10:11 AnderssonPeter

@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

AnderssonPeter avatar Nov 25 '21 09:11 AnderssonPeter

@lvermeulen Is this project still maintained?

AnderssonPeter avatar Jan 03 '22 09:01 AnderssonPeter

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

adhip94 avatar Feb 17 '22 09:02 adhip94

@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...

AnderssonPeter avatar Feb 17 '22 11:02 AnderssonPeter

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

AnderssonPeter avatar Mar 18 '22 13:03 AnderssonPeter

Now there is a nuget https://www.nuget.org/packages/Keycloak.Net.Core/

AnderssonPeter avatar Mar 22 '22 07:03 AnderssonPeter