I am trying to connect Keycloak running on local Kubernetes cluster with Spring Security OAuth application. When I port-forward Keycloak from k8s using kubectl port-forward svc/keycloak 8080:8080
I can access web GUI with no problem, but when Authorizing with Spring Security, it will always throw an error
Invalid token issuer. Expected 'http://localhost:8080/auth/realms/master', but was 'http://10.104.81.255:8080/auth/realms/master'
Here is my Keycloak configuration in Spring
keycloak:
realm: master
auth-server-url: http://localhost:8080/auth
ssl-required: external
resource: my-resource
use-resource-role-mappings: true
public-client: true
Please let me know how I can set this up, so I can continue developing locally.
NOTE: When the Spring Application runs within the cluster and I port-forward that one instead, it obviously works perfectly.
CodePudding user response:
It looks like you haven't configured the frontendUrl
for the Hostname provider. Set it to http://localhost:8080/auth
and you should be fine.