apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.51k stars 2.52k forks source link

help requested: openid-connect: Instability linked to the parse_domain method #11622

Open remiborredon opened 1 month ago

remiborredon commented 1 month ago

Current Behavior

Hello,

I'm using Apisix for protecting a SoapAPI with openid. My identity provider is Keycloak and is located one VM and Apisix and my service are located in a Microk8s cluster located in an other VM.

image

My issue is that sometimes (not always), APISIX is not able to resolve the keycloak DNS address (see in the error logs section)

The Soap route is the following: id: mysoaproute uri: /Bombardier/Transport/Orbiflo/Common/FileRepositoryService/Service.svc plugins: openid-connect: client_id: soap-id client_secret: client-secret discovery: keycloak-DNS-name/realms/myrealm/.well-known/openid-configuration scope: "openid profile" bearer_only: true realm: myrealm upstream: type: roundrobin nodes: path-of-the-service

I have no idea on the way to proceed to investigate this issue.

Thanks in avance for your help!

Expected Behavior

The openid module shall be able to contact keycloak at each request.

Error Logs

2024/10/03 14:15:37 [error] 50#50: 71038 [lua] resolver.lua:80: parsedomain(): failed to parse domain: keycloak-DNS-name, error: failed to query the DNS server: dns server error: 3 name error, client: xx.xx.xx.xx, server: , request: "GET /mySoapSvc HTTP/1.1", host: "cluster-dns-name" 2024/10/03 14:15:37 [error] 50#50: 71038 [lua] openidc.lua:525: call_tokenendpoint(): accessing introspection endpoint (https://keycloak-DNS-name/realms/myrealm/protocol/openid-connect/token/introspect) failed: failed to parse domain: failed to query the DNS server: dns server error: 3 name error, client: xx.xx.xx.xx, server: , request: "GET /mySoapSvc HTTP/1.1", host: "cluster-dns-name" 2024/10/03 14:15:37 [error] 50#50: 71038 [lua] openid-connect.lua:503: phasefunc(): OIDC introspection failed: accessing introspection endpoint (https://keycloak-DNS-name/realms/myrealm/protocol/openid-connect/token/introspect) failed: failed to parse domain: failed to query the DNS server: dns server error: 3 name error, client: xx.xx.xx.xx, server: , request: "GET /mySoapSvc HTTP/1.1", host: "cluster-dns-name" 2024/10/03 14:15:37 [warn] 50#50: 71038 [lua] plugin.lua:1160: runplugin(): openid-connect exits with http status code 401, client: xx.xx.xx.xx, server: , request: "GET /mySoapSvc HTTP/1.1", host: "cluster-dns-name"

Steps to Reproduce

  1. Generate the JWT token
  2. Try to access the soap api using a curl command

Environment

shreemaan-abhishek commented 1 month ago

The DNS problem looks like a generic issue. Does this issue exist in the forementioned setup only? Have you tried to narrow down the problem?