I am following the steps on https://blog.jdriven.com/2019/11/spring-cloud-gateway-with-openid-connect-and-token-relay/ , using a gateway and a microservice. Everything works fine, but when I try to exclude a resource (like for example "somepage.html") in the microservice, it does not work, I always get redirected to the keycloak login.
I tried to in the config part of the service to add
http.authorizeRequests()
.antMatchers("/index*")
.permitAll();
but it did not work, I added this part to the config:
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/public/**");
}
but it did not help either... This is the gateway config file:
server:
port: 8080
spring:
application:
name: travel-spring-cloud-gateway
security:
oauth2:
client:
provider:
keycloak:
issuer-uri: http://localhost:8090/auth/realms/spring-cloud-gateway-realm
user-name-attribute: preferred_username
registration:
keycloak:
client-id: spring-cloud-gateway-client
client-secret: 3a456790-c720-4208-9d4b-fb230ea03dc1
cloud:
gateway:
default-filters:
- TokenRelay
routes:
- id: front-service
uri: http://127.0.0.1:8086/front
predicates:
- Path=/front/**
How can I make the gateway (or the microservice) prevent a request from being redirected to the keycloak login?