keycloak / keycloak/keycloak-nodejs-connect

Port number problem in post_logout_redirect_uri with ipv6 addresses

Open
#424 0 comments 0 reactions 0 assignees View on GitHub
kind/bug status/triage
Dominant language
JavaScript
Stars
740
Forks
442
PR merge metrics
No merged PRs in 30d

Description

### 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_

Contributor guide

Open the contributing guide

Research direction

Search the logout redirect URI generation and port-parsing entry point for handling of the request host. Add a regression case using [2001:db8:4006:812::200e]:8080, then run the relevant tests. Done means the generated post_logout_redirect_uri preserves the IPv6 address and port as [2001:db8:4006:812::200e]:8080.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.