fix: preserve operator scopes for shared auth connections

When connecting via shared gateway token (no device identity),
the operator scopes were being cleared, causing API operations
to fail with 'missing scope' errors.

This fix preserves scopes when sharedAuthOk is true, allowing
headless/API operator clients to retain their requested scopes.

Fixes #27494

(cherry picked from commit c71c8948bd693de0391f861c31d4d6c2cce96061)
This commit is contained in:
Kevin Shenghui
2026-02-26 04:11:19 -08:00
committed by Peter Steinberger
parent 0ab5f4c43b
commit 9c142993b8

View File

@@ -486,7 +486,7 @@ export function attachGatewayWsMessageHandler(params: {
close(1008, truncateCloseReason(authMessage));
};
const clearUnboundScopes = () => {
if (scopes.length > 0 && !controlUiAuthPolicy.allowBypass) {
if (scopes.length > 0 && !controlUiAuthPolicy.allowBypass && !sharedAuthOk) {
scopes = [];
connectParams.scopes = scopes;
}