Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Possible typo in source code for static upstreams #2622

Open
anonhostpi opened this issue Apr 30, 2024 · 2 comments
Open

[Bug]: Possible typo in source code for static upstreams #2622

anonhostpi opened this issue Apr 30, 2024 · 2 comments

Comments

@anonhostpi
Copy link

anonhostpi commented Apr 30, 2024

OAuth2-Proxy Version

v7.6.0

Provider

None

Expected Behaviour

As far as I am aware, there is no reason that static URIs should host web socket connections.

According to this line, if Upstream.ProxyWebSockets is set to nil, it should use the default behavior (not false), which is to proxy any web socket connections to that Upstream

Current Behaviour

However according to the source code, when using a "static" URI upstream, it uses sets ProxyWebSockets to nil instead of false, which means that it will proxy web socket connections to the static file (which doesn't make sense):

switch u.Scheme {
...
case "static":
...
  upstream.ProxyWebSockets = nil # probably got `nil` confused with `false`
  • see:
    case "static":
    responseCode, err := strconv.Atoi(u.Host)
    if err != nil {
    logger.Errorf("unable to convert %q to int, use default \"200\"", u.Host)
    responseCode = 200
    }
    upstream.Static = true
    upstream.StaticCode = &responseCode
    // This is not allowed to be empty and must be unique
    upstream.ID = upstreamString
    // We only support the root path in the legacy config
    upstream.Path = "/"
    // Force defaults compatible with static responses
    upstream.URI = ""
    upstream.InsecureSkipTLSVerify = false
    upstream.PassHostHeader = nil
    upstream.ProxyWebSockets = nil
    upstream.FlushInterval = nil
    upstream.Timeout = nil

Steps To Reproduce

I discovered this while reviewing source code. I don't quite yet have a way to test if this is genuinely an issue.

Possible Solutions

Set Upstream.ProxyWebSockets to false instead of nil for static URIs

Configuration details or additional information

No response

@anonhostpi
Copy link
Author

Oh I just realized the static:// URI format is used for status codes, and not files. I'm still not entirely sure why web sockets would be proxied for HTTP status codes.

@anonhostpi
Copy link
Author

This also makes me think that setting it to nil instead of false was unintentional:

msgs = append(msgs, fmt.Sprintf("upstream %q has proxyWebSockets, but is a static upstream, this will have no effect.", upstream.ID))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant