lvermeulen / Keycloak.Net

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

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

Closed AnderssonPeter closed 1 year ago

AnderssonPeter commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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

AnderssonPeter commented 2 years ago

@lvermeulen Is this project still maintained?

adhip94 commented 2 years ago

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

AnderssonPeter commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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