Spring cloud gateway and Keycloak invalid credentials

40 Views Asked by At

I have a set up with a Spring Cloud Gateway service that redirect the requests from my frontend apps to my backend services. I want some of those requests to be authenticated, so I have a keycloak server also running. Both services runs inside docker and share a docker network. I have tried to run the Spring cloud gateway outisde the docker network and it works fine, I am able to login using the keycloak form, but once I set up the docker setup, when I try to login with the correct credentials I get this page as result, the IP is my wsl ip, where the docker is running and also used in the configuration as keycloak-host.

invalid credentials

This is my application.yml configuration:

server:
  port: 8080
spring:
  cloud:
    gateway:
      default-filters:
        - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin Access-Control-Request-Headers
        - SaveSession
        - TokenRelay=
      routes:
        - id: resource
          uri: ${postman-mock}
          predicates:
            - Path=/resource

  security:
    oauth2:
      client:
        provider:
          keycloak:
            issuer-uri: ${keycloak-host}/realms/${realm}
            user-name-attribute: preferred_username #here also tried with email
        registration:
          keycloak:
            provider: keycloak
            client-id: ${client-id}
            client-secret: ${client-secret}
            authorization-grant-type: authorization_code
            scope:
              - openid
              - profile
              - email
              - roles
      resourceserver:
        jwt:
          issuer-uri: ${keycloak-host}/realms/${realm}

In the keycloak configuration I have tried multiple Valid redirect URIs & Valid post logout redirect URIs but currently both have * set.

Any idea of the possible issue?

0

There are 0 best solutions below