-
With reference to https://www.baeldung.com/spring-boot-keycloak and this repo's samples I was able to get most of the way there.
The inspected token generated by keycloak told me: "iss": "http://localhost:8442/realms/baeldung-keycloak",
"aud": "account", For full details on the setup (keycloak branch): https://github.com/BenVella/backend-java/tree/keycloak My properties are: # See https://github.com/ch4mpy/spring-addons/blob/master/samples/webmvc-jwt-default
com:
c4-soft:
springaddons:
oidc:
cors:
- path: /**
allowed-origin-patterns: ${origins}
ops:
- iss: http://localhost:8442/realms/baeldung-keycloak
username-claim: preferred_username
authorities:
- path: $.realm_access.roles
- path: $.resource_access.*.roles
resourceserver:
permit-all:
- /no-op
- /greet/public
- /actuator/health/readiness
- /actuator/health/liveness
- /v3/api-docs/** And keycloak is on docker compose with similar details. It's probably incredibly obvious but I can't quite work out why it's not resolving an appropriate OpenId Provider... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
And... it looks like it boils down to me always running cached builds. I need to look into that cause it's happened a few times already. Copy pasting the expected url did solve the issue but I was then running the cached build with the originally wrong properties🤦 That then meant that the issuer-uri was correct but not reachable. I was very confused on that front so I tried adding expose:8442 for keycloak. It didn't matter, it was always targeting localhost:8442, but localhost meant the app's own localhost. Solution was changing it to keycloak:8442 in issuer uri to reach that container, but of course that sent me back to the original error, keycloak was minting its tokens and marking itself as issuer on localhost. So updating keycloak's docker compose to:
Just to cover the basics for whichever poor soul finds themselves in my position, the above will mint jwts with issuer com:
c4-soft:
springaddons:
oidc:
cors:
- path: /**
allowed-origin-patterns: ${origins}
ops:
- iss: http://keycloak:8442/realms/baeldung-keycloak
username-claim: preferred_username
authorities:
- path: $.realm_access.roles
- path: $.resource_access.*.roles
resourceserver:
permit-all:
- /no-op
- /greet/public
- /actuator/health/readiness
- /actuator/health/liveness
- /v3/api-docs/** |
Beta Was this translation helpful? Give feedback.
And... it looks like it boils down to me always running cached builds. I need to look into that cause it's happened a few times already. Copy pasting the expected url did solve the issue but I was then running the cached build with the originally wrong properties🤦
That then meant that the issuer-uri was correct but not reachable. I was very confused on that front so I tried adding expose:8442 for keycloak. It didn't matter, it was always targeting localhost:8442, but localhost meant the app's own localhost.
Solution was changing it to keycloak:8442 in issuer uri to reach that container, but of course that sent me back to the original error, keycloak was minting its tokens and marking itse…