So this PR checks the server version and conditionally adds the /policy-type part or omits it. If the Keycloak version is >=20.0.0 the part is omitted. In order to not hit the serverinfo endpoint everytime, I've added the version field to Gocloak.Config so the API would only have to be called once.
I've noticed that the tests on main are already failing so I haven't made any attempt to edit the test cases. Let me know if this will be a blocker. I've tested the policy fetching on v19.0.0v20.0.0, v24.0.0 and it seems to work as intended in each one of these cases.
In Keycloak versions >=
20.0.0
. The endpoint to get/create/update the policies has been changed. It no longer includes the/policy-type
part.Similar to https://github.com/Nerzal/gocloak/issues/286, I was facing this issue while running on Keycloak
v24.0.1
and I couldn't use the policies endpoints.So this PR checks the server version and conditionally adds the
/policy-type
part or omits it. If the Keycloak version is>=20.0.0
the part is omitted. In order to not hit the serverinfo endpoint everytime, I've added theversion
field toGocloak.Config
so the API would only have to be called once.I've noticed that the tests on
main
are already failing so I haven't made any attempt to edit the test cases. Let me know if this will be a blocker. I've tested the policy fetching onv19.0.0
v20.0.0
,v24.0.0
and it seems to work as intended in each one of these cases.