Skip to content

Port number problem in post_logout_redirect_uri with ipv6 addresses #424

@acerola1

Description

@acerola1

Describe the bug

In a corporate cloud environment we use ipv6 addresses. When the redirect uri is not defined keycloak-connect create a redirect-ui based on the request host for the logout. When the host is an ipv6 address, then parsing out the port number is not working right. It adds part of the ipv6 address instead of the real port number.

Version

19

Expected behavior

When the host of the request is an ipv6 address like [2001:db8:4006:812::200e]:8080 then the generated post_logout_redirect_uri should be [2001:db8:4006:812::200e]:8080

Actual behavior

Now the generated post_logout_redirect_uri is [2001:db8:4006:812::200e]:db8

How to Reproduce?

It is hard to reproduce, because it is not a normal use case that you use ipv6 ip address for a website. I think in out case it is caused by some kind of proxying inside the cloud environment. But it is a simple parsing problem. The port parsing for ipv6 should be different. Something like this.

let getPort = (url) => {
    let res;
    if (isIpv6Address(url)) {
        res = url.split(']');
        res = res[1].split(':');
    } else {
        res = url.split(':');
    }
    return res[1] || '';
} 

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions