Fix websocket auth for managed/custom servers behind using bearer-token auth - #2583
Open
jonlamhk wants to merge 1 commit into
Open
Fix websocket auth for managed/custom servers behind using bearer-token auth#2583jonlamhk wants to merge 1 commit into
jonlamhk wants to merge 1 commit into
Conversation
…initial websocket connect Updated websocket connection logic to use token from settings.json server_authorization if available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Connecting to a ComfyUI server protected by bearer-token
auth (e.g. ComfyUI-Login) in managed or custom-server mode fails at the initial connection:
HTTP requests authenticate correctly (Authorization header is set from
settings.server_authorization in init), but the websocket handshake in
connect() is rejected and redirected to the login page, which comes back as
HTTP 200 instead of a 101 upgrade.
Cause
In ComfyClient.connect(), the initial websocket test builds its args from
self._token:
self._token is only populated for cloud (Interstice) connections, so in
managed/custom mode it is empty and no Authorization header is sent on the
handshake. The ongoing listener in _listen() already uses the correct value
(settings.server_authorization).
Fix
Use settings.server_authorization (falling back to self._token) so the
handshake carries the same bearer token as the HTTP requests and the
listener:
Tested against liusida/ComfyUI-Login; the connection now upgrades correctly.