Skip to content

Websockets not working #546

Description

@Zoey2936

Hello, it seems that websocket connections are always blocked, see: ZoeyVid/NPMplus#1606
This is the config used:

access_by_lua_block {
    local opts = {
        redirect_uri = "/npmplus-oidc/redirect_uri",
        discovery = "https://<oidc-provider>/.well-known/openid-configuration", -- edit
        client_id = "", -- edit
        client_secret = "", -- edit
    }
    local session_opts = {
        cookie_prefix = "LRNP-OIDC-",
        cookie_http_only = true,
        cookie_secure = true,
        cookie_same_site = "Strict",
        remember = true
    }
    local res, err = require("resty.openidc").authenticate(opts, nil, nil, session_opts)
    if err then
        ngx.status = 500
        ngx.say(err)
        ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
    end
    ngx.req.set_header("X-USER", res.id_token.sub)
}

Adding the following fixes it, but makes all websocket request unprotected:

    if ngx.var.http_upgrade and string.lower(ngx.var.http_upgrade) == "websocket" then
        return
    end

Since I can't test it, because I have no openidc service myself, @shedowe19 made the tests for me (see the linked Issue), where we found this bug and the possible workaround

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions