mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
The Kubernetes client code was wrapping all IP addresses (both IPv4 and IPv6) in square brackets when constructing the API server URL. This was based on an incorrect assumption that IPv4 addresses in brackets are valid in a URL. Recent versions of Go (1.25.2 and later) have stricter URL parsing that conforms to RFC 3986. This causes a failure when running Dex in a Kubernetes environment where the KUBERNETES_SERVICE_HOST is an IPv4 address, leading to the error "invalid IPv6 host". This commit changes the logic to only wrap IPv6 addresses in square brackets. It uses `ip.To4() == nil` to reliably detect if an IP address is IPv6 before wrapping it. This ensures that URLs are correctly formatted for both IPv4 and IPv6 addresses, fixing the incompatibility with newer Go versions. Signed-off-by: Rene Dekker <rene@tigera.io>