Skip to content

Fixes #36608: Close push-feed sockets when the authentication provider changes - #38248

Merged
yan-3005 merged 5 commits into
open-metadata:mainfrom
Vamsi-klu:fix/36608-push-feed-provider-currency
Nov 24, 2026
Merged

yan-3005 merged 5 commits into
open-metadata:mainfrom
Vamsi-klu:fix/36608-push-feed-provider-currency

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36608

Push-feed sockets (/api/v1/push/feed/*) ignored the rule REST already enforces: a session issued by an authentication provider that is no longer configured stops working (ADR:2026-10-20-a-refresh-ends-sessions-issued-by-a-provider-no-longer-configured). On main there were three gaps:

  • Cookie handshake. SocketAddressFilter.validateSessionStillActive checked status, expiry and the identity bindings, but not the session's provider. Both session handshake paths (cookie only, and cookie plus a claim-less token) go through it.
  • Socket sweep. WebSocketManager.isSessionActiveForUser, run every 60 s, had the same gap, so an open session-bound socket lived until its session expired (7 days by default).
  • Sockets without a session. Under the default public-client SSO setup the UI opens the socket with the provider's token and no OM_SESSION cookie. Such a socket has no session, the sweep never re-checks it, and it outlived the provider swap until the client closed it. This is the issue's own Google to Azure example.

One clarification: a handshake that presents an OM token with a sessionId claim was already rejected, because the handshake runs JwtFilter.checkValidationsForToken, which calls validateSessionProviderIsCurrent. The exposed session path was the cookie.

The fix makes SessionProviders.isFromAnotherProvider the one predicate. REST, refresh, the handshake and the sweep decide through it. A security reload that really changes the provider closes every socket on the server that applies it, with or without a session. A basic/openmetadata rename closes nothing.

Type of change:

  • Bug fix

High-level design:

Change Where What
C1 SessionProviders.isFromAnotherProvider(String, AuthProvider) The single predicate: the null guards plus isSameProvider.
C2 SessionService.isFromAnotherProvider(UserSession) Private to public; delegates to C1 with this server's live provider (reads the volatile config once).
C3 JwtFilter.validateSessionProviderIsCurrent Uses C1 with the filter's own providerType. No behavior change.
C4 SocketAddressFilter.validateSessionStillActive Also rejects a session from another provider: 401 "Session is no longer active", the existing status and message.
C5 WebSocketManager.isSessionActiveForUser The sweep closes such sockets at its next pass, judged against the provider the socket filter validates under (C8).
C6 WebSocketManager.disconnectAll(), and OpenMetadataApplication.pushFeedReloadListener, which initializeWebsockets registers The listener rebuilds the socket filter's validator, remembers the provider the previous reload (or the boot) applied, and through closeSocketsOnProviderSwitch(previous, current, manager) closes every socket on the server when the provider changes. It looks the manager up when a reload fires, as the feed servlet does.
C7 SocketAddressFilter.authenticate stamps an AuthProvider header; WebSocketManager.onConnection (added in 2f8f1d6) The handshake stamps the provider of the filter that validated it. The socket registers when its CONNECT arrives, then compares that stamp with the provider the filter validates under now, and closes on a mismatch.
C8 SocketAddressFilter.validatingProvider(); WebSocketManager built on it through OpenMetadataApplication.buildPushFeedSockets (added in bf7dd8f) Registration (C7) and the sweep (C5) read the provider the socket filter validates under, not the published configuration or SessionService's. Only the reload listener rebuilds the filter, and only for a reload that succeeded.

Why each piece:

  • C6 is the only thing that can reach a socket without a session: nothing re-checks such a socket, so only the reload event can close it. Each pod runs the listener on its own reload (settings watcher, or a Redis settings message), after SessionService and the socket filter already hold the new configuration. A failed reload rolls back without notifying listeners, so nothing closes.
  • C4 stays because a client can reconnect with only its cookie after C6 closed everything.
  • C5 stays because a session-bound handshake can validate before a pod's reload and register after C6 ran; the sweep catches it within one interval.
  • C7: a socket registers one round trip after its handshake, so a handshake validated just before a switch can register after C6 closed every socket, and a sessionless socket is never swept. The socket registers before its check, and the listener rebuilds the filter before disconnectAll, so whichever runs second catches it.
  • C8: reloadSecuritySystem publishes the new configuration, and reinitializeAuthSystem hands it to SessionService, before the new authenticator initializes, and both roll back if that fails (a Google to LDAP save whose LDAP server cannot be reached, say). Judged against either, a socket that registered or was swept in that window was closed, and it stayed closed after the rollback because the UI does not reconnect after a server close. The handshake's own session check (C4) stays on SessionService: in that window it answers 401, which the UI retries, as REST does then.
  • Sockets are closed, sessions are not revoked, matching JwtFilter. Revoking would be irreversible on a swap back, and a pod still on the old configuration would end sessions the new provider issued (the stale-pod hazard ADR 2026-10-20 records).
  • C6 is gated on a real provider change. Closing on any security reload would drop every user's feed when an admin saves, say, the session expiry, and the UI does not reconnect after a server close.

Rejected alternatives:

  • Copy JwtFilter's guard into the socket sites: re-derives the check, which is how this bug happened.
  • Route the socket paths through JwtFilter.validateSessionBoundToken: private, needs token claims, the sweep has no JwtFilter, and it accepts REFRESHING.
  • Have JwtFilter call SessionService.isFromAnotherProvider: one request would be judged under two configuration snapshots, and candidate-configuration filters (TestLoginService, SystemRepository) would judge against the live configuration.
  • Only C4 and C5 (the issue's suggestion): misses sockets without a session, which are the SSO default.
  • Only C6: a cookie-only reconnect would succeed after the close, and the reload race would slip through.
  • Bulk-revoke other-provider sessions on reload: irreversible and a cluster-wide write on each pod's reload.

Compatibility and rollout:

  • No schema change, no migration, no UI change. Public additions only: SessionProviders.isFromAnotherProvider, SessionService.isFromAnotherProvider (was private), WebSocketManager.disconnectAll, SocketAddressFilter.validatingProvider, WebSocketManagerBuilder.build(EngineIoServerOptions, Supplier<AuthProvider>) (the one-argument build stays and applies no provider). No signature is removed or renamed.
  • Behavior change, disclosed: switching the authentication provider now closes every open push-feed connection on each server, bot and PAT sockets included. The UI shows io server disconnect, which it does not retry; the next REST call answers 401 and the app signs out. After a swap back, the feed returns at the next page load.
  • Log text: the handshake rejection line now reads "is not active or its provider is no longer configured", and a provider switch logs "Authentication provider changed from to ; closing every push-feed socket on this server" before the per-user "Force-disconnecting" lines. A socket closed at registration logs "Closing socket for user : its handshake was validated under provider

    , but the push feed validates under now".

Release note: "Switching the authentication provider now closes every open push-feed (WebSocket) connection, and a sign-in from a provider that is no longer configured can no longer open one."

Known limits, filed separately:

Tests:

Use cases covered

  • Google to Azure under the public client: every socket on the pod closes at that pod's reload (T7, T6).
  • basic to OIDC: the reload closes all sockets; a cookie-only reconnect gets 401 (T7, T3, T8).
  • LDAP to basic, OIDC to SAML: treated as switches (T1, T7).
  • basic to openmetadata: not a switch; no socket closes and the cookie handshake is accepted (T1, T4, T7).
  • A security save that keeps the provider: nothing closes (T7, GOOGLE to GOOGLE).
  • A user with sessions from two providers: the sweep closes only the old provider's sockets (T5).
  • Null or empty session provider, or no configured provider: not a switch (T1).
  • Successive reloads: each is compared with the provider the previous reload applied, so a save made after the switch closes nothing (T9).
  • A handshake validated under the old provider whose CONNECT arrives after the switch: closed at registration; one validated under the new provider is kept (T10, T12).
  • A Google to LDAP save whose LDAP initialization fails: no socket closes, including sockets that register during the reload and session-bound sockets swept in that window (T13, T14).

Unit tests

  • I added unit tests for the new/changed logic.
  • T1 SessionProvidersTest#isFromAnotherProvider_judgesOnlyAKnownSessionProviderAgainstAConfiguredOne (10 rows)
  • T2 SessionServiceTest#isFromAnotherProvider_followsTheConfigurationThisServerRunsNow
  • T3 SocketAddressFilterTest#cookieHandshakeIsRejectedWhenItsSessionsProviderIsNoLongerConfigured
  • T4 SocketAddressFilterTest#cookieHandshakeAcceptsTheOtherNativePasswordProviderName
  • T5 WebSocketManagerTest#disconnectInactiveSessions_closesSocketsWhoseSessionProviderIsNoLongerConfigured
  • T6 WebSocketManagerTest#disconnectAll_closesSessionBoundAndSessionlessSockets
  • T7 OpenMetadataApplicationAuthReloadTest#closeSocketsOnProviderSwitch_closesOnlyOnAProviderSwitch (4 rows)
  • T9 OpenMetadataApplicationAuthReloadTest#pushFeedReloadListener_closesSocketsOnlyWhenAReloadChangesTheProvider: the registered listener, booted under Google, fires Google (nothing closes), Azure (the session-bound and the sessionless socket close), then Azure again with a newly opened socket (nothing closes).
  • T10 WebSocketManagerTest#onConnection_closesASocketValidatedUnderTheOldProviderThatRegistersAfterTheSwitch: the switch is made as a successful reload makes it (publish, then rebuild the filter, then disconnectAll); the late Google sockets, sessionless and session-bound, close and the Azure one stays.
  • T11 WebSocketManagerTest#onConnection_keepsASocketValidatedUnderTheOtherNativePasswordProviderName
  • T12 SocketAddressFilterTest#handshakeIsStampedWithTheProviderOfTheFilterThatValidatedIt (a client-sent AuthProvider header is dropped)
  • T13 WebSocketManagerTest#onConnection_keepsASocketThatRegisteredDuringAReloadThatFailed: drives the real SecurityConfigurationManager.reloadSecuritySystem() (SettingsCache hands Google at boot and LDAP at the reload). While reinitializeAuthSystem runs, a sessionless and a session-bound socket validated under Google register; then it throws, as an unreachable LDAP server would. Asserts LDAP was published in the window, the reload rolled back to Google and notified no listener, and both sockets are open and registered.
  • T14 WebSocketManagerTest#disconnectInactiveSessions_keepsSocketsWhileAReloadHasNotAppliedItsProvider: SessionService is handed LDAP while the filter still validates under Google; the Google session's socket stays.
  • T15 OpenMetadataApplicationAuthReloadTest#buildPushFeedSockets_sweepsAgainstTheProviderTheHandshakeFilterValidatesUnder: the manager initializeWebsockets builds follows its filter, not SessionService.
  • T16 SocketAddressFilterTest#validatingProviderNamesTheProviderTheFilterValidatesUnder

T3 to T5 use a real SessionService over a mocked SessionStore, and a real WebSocketManager with mocked SocketIoSockets. T10, T11, T13 to T15 build the manager on a real SocketAddressFilter (PushFeedFilters, which installs the test signing key first, so no test depends on another having installed it).

RED on the fix-less tree (commit 5717211, tests only):

SocketAddressFilterTest.cookieHandshakeIsRejectedWhenItsSessionsProviderIsNoLongerConfigured:485 Expected org.openmetadata.service.socket.HandshakeRejectedException to be thrown, but nothing was thrown.
WebSocketManagerTest.disconnectInactiveSessions_closesSocketsWhoseSessionProviderIsNoLongerConfigured:205
Wanted but not invoked: socketIoSocket.disconnect(true); Actually, there were zero interactions with this mock.
Tests run: 37, Failures: 2, Errors: 0, Skipped: 0

Mutation checks on the fix:

  • Dropping the configuredProvider != null guard in C1 fails T1 (NullPointerException on the google/null row).
  • Dropping the provider-switch gate in closeSocketsOnProviderSwitch fails T7's no-switch rows (run before the two unreachable null rows were removed).
  • In pushFeedReloadListener, getAndSet(current) replaced by get() fails T9 (the socket opened after the switch is closed by the next save); an empty initial AtomicReference fails T9 with a NullPointerException on the first reload.

RED for the failed-reload window (bf7dd8f's tests against the checks as they were at 2f8f1d6):

WebSocketManagerTest.onConnection_keepsASocketThatRegisteredDuringAReloadThatFailed
NeverWantedButInvoked: socketIoSocket.disconnect(<any boolean>);
WebSocketManagerTest.disconnectInactiveSessions_keepsSocketsWhileAReloadHasNotAppliedItsProvider
NeverWantedButInvoked: socketIoSocket.disconnect(<any boolean>);

Building the manager with the one-argument build (no provider) fails T15: Wanted but not invoked: socketIoSocket.disconnect(true). In each run every other test in the classes passed.

GREEN (mvn -o -pl openmetadata-service test with jacoco, commit 251b197), 10 classes: SessionProvidersTest 13, SessionServiceTest 46, SocketAddressFilterTest 25, SocketAddressFilterSpoofRevalidationBypassTest 3, WebSocketManagerTest 14, JwtFilterTest 106, Jetty12WebSocketHandlerTest 7, OpenMetadataApplicationPushFeedUpgradeTest 3, OpenMetadataApplicationAuthReloadTest 10, OpenMetadataApplicationTest 1. Tests run: 228, Failures: 0, Errors: 0, Skipped: 0.

Changed-line coverage (jacoco, the 10 classes above): 25 of 27 changed executable lines.

  • SessionProviders, SessionService, JwtFilter, SocketAddressFilter, WebSocketManager: every changed line covered (13/13).
  • OpenMetadataApplication: 12/14. pushFeedReloadListener and closeSocketsOnProviderSwitch are fully covered. The two uncovered lines are the arguments of the registration call in initializeWebsockets, which runs only when a server boots (every IT node boots through it).
  • Class totals for OpenMetadataApplication, JwtFilter and SessionService predate this change, so changed-line coverage is reported instead.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/.
  • T8 SessionMultiNodeIT#pushFeedHandshakeRejectsASessionIssuedByAProviderNoLongerConfigured: logs in on node A (basic); a cookie-only polling handshake on node B answers 200; the session row's provider is rewritten to google; REST on B answers 401 (already true on main); the handshake on B answers 401.

T8 results:

  • RED, MySQL + Elasticsearch, commit 5717211 (tests only): expected: <401> but was: <200> on the post-switch handshake (the body was the engine.io open packet). The 200 control and the REST 401 passed.
  • GREEN, MySQL + Elasticsearch: the whole SessionMultiNodeIT class through make java_affected_run, 12 run, 0 failed (T8 included), on 93a803a and again on the final 251b197 (block below).
  • GREEN, PostgreSQL + OpenSearch: commit 93a803a (before the review amendment, which changed only the listener wiring in OpenMetadataApplication and its unit test), -Ppostgres-opensearch -DintegrationTests.lane=global-state -Dit.test='SessionMultiNodeIT#pushFeedHandshakeRejectsASessionIssuedByAProviderNoLongerConfigured': 1 run, 0 failed. This also exercises the Postgres branch of the test's persistSession helper.

Local Java test run: PASSED

  • Commit: bf7dd8fba493 (base origin/main)
  • Finished: 2026-11-24 07:24 UTC · 44.9 min
  • Details: the classes each step ran, why these tests, the commands
  • Scope: focused; merge readiness is not established. Broader steps deferred: 9 (run --scope full).
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-service (10 classes) 10 235 0 0 11.5 passed
integration mysql-elasticsearch · isolated 1 12 0 0 33.4 passed
  • Impacted, not run locally: 13 classes (listed in the details)

The run was make java_affected_run ARGS='--scope focused --add-unit SocketAddressFilterSpoofRevalidationBypassTest,Jetty12WebSocketHandlerTest,OpenMetadataApplicationPushFeedUpgradeTest --reason "..."'; the three added classes exercise the handshake paths SocketAddressFilter and the upgrade creator share. The 9 broader steps the focused scope defers (the wider unit set and the area IT lanes) were not run here; the merge queue runs them.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • Not run by hand: the listener check from the plan (start a local stack, open a push-feed socket, switch the provider in Settings → SSO, and watch the socket close with io server disconnect; repeat with basic → openmetadata and see nothing close). It needs a full local server image and an SSO provider switch in a browser. T9 now drives the registered listener through the same sequence in a unit test, so only its registration at boot and the browser's reaction are untested.
  • The plan's curl step (curl -i -H "Cookie: OM_SESSION=…" "$HOST/api/v1/push/feed/?EIO=4&transport=polling" answering 401 after the session row's provider is changed, 200 before) is what T8 automates against two real server nodes; it was not repeated by hand.

UI screen recording:

Not applicable: backend-only fix.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: not applicable, no schema change.

  • For a UI feature or feature task: not applicable, backend-only fix.

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
    Self-review against REVIEW.md: a fresh-reviewer pass ran on 93a803a; its findings are applied in 251b197 (a unit test for the reload listener, a log line on a provider switch, unreachable null guards removed). The nit to split the handshake rejection branch was declined: the client gets the same 401 and body either way. The 93a803a..251b197 delta was then re-read against REVIEW.md: no new findings.

  • Decision check: amends ADR:2026-10-20-a-refresh-ends-sessions-issued-by-a-provider-no-longer-configured (v2): push-feed sockets follow the rule, and the reload closes sockets on a provider switch. The session design doc (§8.1, §8.4) is updated to match. The v2 text also records the registration check (C7) and that registration and the sweep judge against the socket filter's provider (C8). The Java impact map needs no change (plan_local_java_tests.py --check-branch passes).

  • I have added a test that covers the exact scenario we are fixing (T3, T5 and T8 fail on main).

RetriggerView in GreptileConfidence Score: 4/5

Fix the failed-reload disconnect before merging.

Findings

  1. P1 Failed reload closes valid feeds ▶

Summary

The PR makes push-feed connections follow authentication-provider changes.

  • Cookie handshakes and socket checks reject sessions from an old provider.
  • A provider switch closes push-feed sockets, including sockets without sessions.

Reviews (7) · Last reviewed commit: "Close a push-feed socket that registers ..." · Reviewed by Greptile

…igured (open-metadata#36608)

Regression tests that fail on main: a cookie handshake for a session issued by a
provider that is no longer configured is accepted (SocketAddressFilterTest,
SessionMultiNodeIT), and the socket sweep keeps such sockets open
(WebSocketManagerTest).
…ation provider changes

Push-feed sockets ignored the rule that a session issued by a provider that is
no longer configured stops working:

- The cookie handshake (SocketAddressFilter.validateSessionStillActive) and the
  60 s socket sweep (WebSocketManager.isSessionActiveForUser) never checked the
  session's provider.
- Sockets opened with a provider token and no session (the default public-client
  SSO setup) are never re-checked at all, so they outlived the swap.

SessionProviders.isFromAnotherProvider is now the one predicate. JwtFilter,
refresh, the handshake and the sweep decide through it, and a security reload
that really changes the provider closes every socket on that server, with or
without a session. A basic/openmetadata rename closes nothing. Sockets are
closed; sessions are not revoked, as JwtFilter does not revoke them either.

Amends ADR 2026-10-20 (v2) and the session design doc (8.1, 8.4).
@Vamsi-klu
Vamsi-klu requested a review from a team as a code owner November 20, 2026 02:35
@Vamsi-klu
Vamsi-klu requested a review from IceS2 November 20, 2026 02:35
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@Vamsi-klu Vamsi-klu left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review against REVIEW.md (independent reviewer, run on 93a803a; fixes in 251b197)

Verdict on 93a803a: needs changes (one should-fix, three nits). The production logic was judged correct.

  1. should-fix, applied: the reload-listener wiring in initializeWebsockets (AtomicReference + getAndSet) had no test, and it is the only thing that closes sessionless public-client sockets. Mutating getAndSet to get, or the initial value to null, left every test green. The listener now comes from OpenMetadataApplication.pushFeedReloadListener, and T9 (OpenMetadataApplicationAuthReloadTest) boots under GOOGLE, then fires GOOGLE (nothing closes), AZURE (both sockets close) and AZURE again (nothing closes). Both mutations now fail T9.
  2. nit, applied: on a switch the only log said "Force-disconnecting ... on session revocation". closeSocketsOnProviderSwitch now logs the previous and current provider first.
  3. nit, applied: removed guards for states the contract excludes (sockets != null, previous != null; the boot config and its provider are always present when initializeWebsockets runs). The two null rows in T7 went with them. C1's guards stay.
  4. nit, declined: split the provider mismatch into its own rejection branch in SocketAddressFilter. The client gets the same 401 and body either way, and the log line names both reasons.

Checked with no finding: removal while iterating the endpoint map in disconnectAll (ConcurrentHashMap, weakly consistent); reload vs handshake ordering (SessionService and the socket filter hold the new config before the close); listeners never overlap (both reload paths are synchronized, a failed reload notifies nobody); the static WebSocketManager in tests (same_thread, rebuilt per test as WebSocketManagerTest already does); sibling UserSession lookups (only JwtFilter and logout). Each of C4, C5 and the C6 gate was reverted on its own, and its test failed.

Not run: the manual SSO switch in a browser (T9 drives the same sequence in a unit test).

@Vamsi-klu

Vamsi-klu commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Local Java test run: PASSED — details

  • Commit: bf7dd8fba493 (base origin/main)
  • The summary is in the PR description.

Tests run locally

  • unit · openmetadata-service (10 classes): Jetty12WebSocketHandlerTest (7 passed), JwtFilterTest (106 passed), OpenMetadataApplicationAuthReloadTest (11 passed), OpenMetadataApplicationPushFeedUpgradeTest (3 passed), OpenMetadataApplicationTest (1 passed), SessionProvidersTest (13 passed), SessionServiceTest (46 passed), SocketAddressFilterSpoofRevalidationBypassTest (3 passed), SocketAddressFilterTest (27 passed), WebSocketManagerTest (18 passed)
  • integration · mysql-elasticsearch · isolated: SessionMultiNodeIT (12 passed)

Broader coverage not executed by this focused run

  • mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AlertingArchitectureTest,AuthenticationCodeFlowHandlerTest,BasicAuthServletHandlerTest,BotTokenCheckTest,DbWebSocketRelayTest,DefaultAuthorizerTest,DistributedJobStatsAggregatorTest,FeedServletTest,HeaderRequestWrapperTest,JWTTokenGeneratorTest,Jetty12WebSocketHandlerTest,JwtFilterTest,LdapAuthServletHandlerTest,McpImpersonationTest,McpReadOnlyModeTest,McpSdkUpgradeTest,McpServerFatalErrorTest,McpServerRequestContextTest,McpServerUnconfirmedTokenTest,MintedTokensAreRecognizedTest,OAuthHttpStatelessServerTransportProviderTest,OntologyPublicationStatusResolverTest,OpenMetadataApplicationAuthReloadTest,OpenMetadataApplicationPushFeedUpgradeTest,OpenMetadataApplicationTest,OpenMetadataOperationsSecurityConfigTest,QuartzProgressListenerTest,RedisSessionStoreTest,ReindexingOrchestratorTest,SamlAuthServletHandlerTest,SearchSettingsMergeUtilRepositoryResolutionTest,SessionProvidersTest,SessionServiceTest,SocketAddressFilterSpoofRevalidationBypassTest,SocketAddressFilterTest,SsoRedirectBoundaryTest,SystemRepositorySecurityConfigValidationTest,SystemRepositorySecuritySettingsTest,SystemResourceSecurityConfigApplyTest,UnifiedAuthTest,WebSocketManagerTest -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<514 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state '-Dit.test=<43 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf '-Dit.test=<38 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=parallel -Dit.test=AlertStateIT,BundleWarmupCertificationIT,ContainerCacheCorrectnessIT,EntityCacheWriteOrderIT,OneTransactionFlushAtomicityIT,RelationshipCacheInvalidationIT,TagRenameCacheIT,UncachedReadIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=global-state -Dit.test=CredentialRedisDownIT,CredentialRedisNoRoundTripIT,SessionRedisMultiNodeIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=parallel -Dit.test=FlattenedChildrenHighlightSearchIT,InheritedFieldPropagationRecoveryIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=global-state -Dit.test=PatchTableEmbeddingIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Psearch-it -DdatabaseType=postgres -DsearchType=opensearch -Djpw.data.mode=ingest '-Dit.test=<32 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
Why these tests
  • added by author: both drive the push-feed handshake path and build the WebSocketManager whose construction this change alters ← OpenMetadataApplicationPushFeedUpgradeTest, SocketAddressFilterSpoofRevalidationBypassTest
Impacted, not run locally (13)
  • RdfCatalogScaleIT → only with -DrdfCatalogScale=true, which no CI lane sets
  • ReindexBenchmarkIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • GoogleSsoSignInUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • EntityLoaderSmokeUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • LongCompoundNameSearchUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • PipelineOwnerIndexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • DistributedAutoTuneReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableAllKindsDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SelectiveFieldReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SimpleReindexTriggerUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • GoogleSsoBootstrapUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • MockIdpSmokeUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
Commands
mvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=Jetty12WebSocketHandlerTest,JwtFilterTest,OpenMetadataApplicationAuthReloadTest,OpenMetadataApplicationPushFeedUpgradeTest,OpenMetadataApplicationTest,SessionProvidersTest,SessionServiceTest,SocketAddressFilterSpoofRevalidationBypassTest,SocketAddressFilterTest,WebSocketManagerTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=SessionMultiNodeIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

@yan-3005

Copy link
Copy Markdown
Contributor

@Vamsi-klu one blocker before this can go in, the race greptile flagged at WebSocketManager.java:234 (thread still unanswered).

On the websocket transport the token is checked once, in authenticateUpgrade, but the socket only enters activityFeedEndpoints in the "connection" handler, when the client's CONNECT packet arrives one round trip later. Nothing re-checks there. So a sessionless handshake that passes the old provider's filter just before the reload, and registers just after disconnectAll, survives the switch: the later sweep skips it because it has no sessionId. The UI forces transports: ['websocket'], so this is the default path the PR targets, and a client that keeps reconnecting can hit the window repeatedly.

Suggested fix: stamp the provider (or a reload generation counter) the handshake was validated under into the initial headers next to UserId/SessionId. In the "connection" handler, register the socket first, then compare against the current provider and disconnect on mismatch. Register-then-recheck closes the window because the config is swapped before notifyListeners runs. Please add a unit test where a socket stamped with the old provider registers after the switch and gets closed.

The rest looks right to me: the single predicate, the handshake + sweep checks, per-pod close via the settings watcher, and the ADR amendment.

@yan-3005 yan-3005 added the To release Will cherry-pick this PR into the release branch label Nov 23, 2026

@yan-3005 yan-3005 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking on the handshake-vs-CONNECT race: a socket validated under the old provider can register after disconnectAll and survive the switch. Details and suggested fix in #38248 (comment)

…-metadata#36608)

The websocket transport validates the token on the upgrade, but the
socket only enters activityFeedEndpoints when the client's CONNECT
arrives a round trip later. A handshake validated under the old
provider just before a reload could register after disconnectAll and
survive the switch; the sweep skips it because it has no session.

The handshake now stamps the provider of the JwtFilter that validated
it (AuthProvider header, next to UserId/SessionId, on both transports).
The connection handler registers the socket first, then compares the
stamp with the configured provider and closes it on a mismatch. The
configuration is swapped before the reload closes sockets, so either
disconnectAll or the registration check catches it.
@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

@yan-3005 thanks, you're right, the gap between the upgrade and CONNECT was open. Pushed 2f8f1d6 with the fix along the lines you suggested.

  • SocketAddressFilter.authenticate reads its JwtFilter once and stamps that filter's provider into the identity. That way the stamp is the provider that actually validated the handshake, not whatever the config says by the time it gets read. Both the websocket and polling paths write it as an AuthProvider header and drop any value the client sent.
  • In the "connection" handler the socket is registered first, then the stamp is compared with SecurityConfigurationManager.getCurrentAuthConfig() through SessionProviders.isFromAnotherProvider, and the socket is closed on a mismatch. Using the same predicate means a basic/openmetadata rename still closes nothing.
  • I moved the connection handler into onConnection so it can be tested directly. onConnection_closesASocketValidatedUnderTheOldProviderThatRegistersAfterTheSwitch registers one socket under GOOGLE, switches to AZURE and runs disconnectAll, then registers late sockets stamped GOOGLE (one sessionless, one with a session) and one stamped AZURE. The GOOGLE ones are closed and only the AZURE one is left. There are also stamping tests for both transports, and the ADR amendment now covers this.

Locally all the socket and auth unit tests pass (236 of them). The new tests also fail if I take out the registration check or either of the two stamps, so they actually cover the fix.

Comment on lines +154 to +156
AuthenticationConfiguration current = SecurityConfigurationManager.getCurrentAuthConfig();
if (current == null
|| !SessionProviders.isFromAnotherProvider(validatedProvider, current.getProvider())) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Failed reload closes valid feeds

disconnectIfValidatedUnderAnotherProvider compares the socket's provider with proposed settings before the reload succeeds. reloadSecuritySystem publishes those settings before rebuilding authentication, while the socket filter keeps its old configuration until the reload listener runs.

During a Google-to-LDAP change, for example, a sessionless socket accepted by the Google filter can be closed here while LDAP initialization waits and then fails. The settings roll back, but the browser does not retry a server disconnect, so its feed stays disconnected.

Compare against the provider successfully applied to the socket filter, while preserving the registration ordering that catches successful switches.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vamsi-klu Please check and fix if it is a relevant one -> Post it in #code-reviews slack channel in the OpenMetadata community slack once everything is green, Thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant, fixed in bf7dd8f. Registration and the sweep now compare against SocketAddressFilter.validatingProvider(), the provider the socket filter actually applied. Only a successful reload's listener changes it, so a failed reload closes nothing. The register-then-recheck order is unchanged. WebSocketManagerTest#onConnection_keepsASocketThatRegisteredDuringAReloadThatFailed runs the real reloadSecuritySystem() through a failed LDAP init and checks that sockets registered mid-reload stay open.

Details: #38248 (comment)

@yan-3005

Copy link
Copy Markdown
Contributor

@Vamsi-klu thanks for 2f8f1d6, it closes the CONNECT race I raised. Two things left:

  1. Greptile's P1 on WebSocketManager.java:156 is real. I checked it against SecurityConfigurationManager.reloadSecuritySystem(): currentState is swapped to the new settings before applyToApplication() runs. A sessionless socket that registers in that window is compared against the proposed provider and closed. If the reload then fails and rolls back, that socket stays closed, and the browser doesn't retry a server-side disconnect. Please compare against the provider actually applied to the socket filter (e.g. record it when the reload listener runs), keeping the register-then-recheck order. Add a unit test where the reload fails after a socket registers.
  2. The red openmetadata-service-unit-tests isn't caused by your change. The failures are EntityRepositoryRestoreTest.bulkHardDeleteSubtree_* (NPE), a test-order flake already fixed on main in 4ecb6d5. Please merge the latest main into the branch when you push the fix above, and it should go green.

open-metadata#36608)

A security reload publishes its configuration, and hands it to
SessionService, before it initializes the new authenticator, and rolls
everything back if that fails. The registration check read the published
configuration and the sweep read SessionService's, so a Google-to-LDAP
save whose LDAP initialization then failed could close Google sockets
that the rolled-back server still accepts. The UI does not reconnect
after a server close, so those feeds stayed down.

Registration and the sweep now judge against
SocketAddressFilter.validatingProvider(). Only the reload listener
rebuilds that filter, and it runs only for a reload that succeeded.
WebSocketManager is built on it through
OpenMetadataApplication.buildPushFeedSockets. A real switch is still
caught either way: the socket registers before its check, and the
listener rebuilds the filter before disconnectAll.

The handshake's session check stays on SessionService: in that window
it answers 401, which the UI retries, as REST does then.
@gitar-bot

gitar-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Provider-based session rejection and server-wide feed closure change authentication access; a provider mismatch could deny valid users' push-feed connections.

Adds provider checks so push-feed sockets (/api/v1/push/feed/*) reject sessions from a provider that is no longer configured, and closes open sockets when the authentication provider changes. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

@yan-3005 thanks for checking it against reloadSecuritySystem. Both points are in bf7dd8f.

1. Greptile's P1. Agreed, it's real. The sweep had the same gap: reinitializeAuthSystem hands SessionService the new config before it initializes the new authenticator. So in a failed Google-to-LDAP reload, the sweep would also close Google session sockets, and they'd stay closed after the rollback.

The fix:

  • Registration and the sweep now compare against the provider the socket filter validates under, SocketAddressFilter.validatingProvider(), rather than the published config or SessionService's.
  • The filter is rebuilt only by the reload listener. A failed reload rolls back without notifying listeners, so it closes nothing.
  • WebSocketManager reads that provider through a supplier it's built with (OpenMetadataApplication.buildPushFeedSockets, called from initializeWebsockets).
  • The register-then-recheck order is unchanged: the socket registers before its check, and the listener rebuilds the filter before disconnectAll, so a real switch is still caught either way.

Tests:

  • WebSocketManagerTest#onConnection_keepsASocketThatRegisteredDuringAReloadThatFailed is the one you asked for. It runs the real reloadSecuritySystem(), with SettingsCache returning Google at init and LDAP at reload. While reinitializeAuthSystem runs, a sessionless socket and a session-bound socket validated under Google register. Then it throws, as an unreachable LDAP server would. The test asserts the reload published LDAP during the window, rolled back to Google and notified no listener, and that both sockets are still open and registered.
  • disconnectInactiveSessions_keepsSocketsWhileAReloadHasNotAppliedItsProvider covers the sweep: SessionService is handed LDAP while the filter is still on Google, and the socket stays open.
  • OpenMetadataApplicationAuthReloadTest#buildPushFeedSockets_sweepsAgainstTheProviderTheHandshakeFilterValidatesUnder pins the wiring. Building the manager without the filter's supplier fails it.
  • The successful-switch tests now switch the way a successful reload does: publish, then the listener rebuilds the filter. The late Google sockets are still closed and the Azure one kept.
  • RED check: with the checks as they were at 2f8f1d6, the failed-reload test and the sweep test fail with NeverWantedButInvoked: socketIoSocket.disconnect, and building the manager without the filter's supplier fails the wiring test. Every other test passed in those runs.

I left the handshake's own session check on SessionService. In that window it answers 401, which the UI retries, and REST answers the same way then. I've updated the ADR amendment and the design doc to match.

2. CI. Merged the latest main (includes 4ecb6d5) into the branch.

The local focused run on bf7dd8f is in the description: 235 unit tests across the 10 impacted classes and SessionMultiNodeIT (12/12, MySQL + Elasticsearch), all passing. The broader lanes are left to the merge queue.

The one red check left is Validate PR Metadata: #36608 isn't in the Shipping project, and I can't add it from a fork. Could you add it there, or put skip-pr-checks on the PR?

@yan-3005 yan-3005 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Vamsi-klu - Merging it

@yan-3005
yan-3005 merged commit 64141df into open-metadata:main Nov 24, 2026
52 of 55 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.1 opened as #38587 (clean cherry-pick). It merges itself once the checks pass.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

yan-3005 pushed a commit that referenced this pull request Nov 24, 2026
…r changes (#38248) (#38587)

* test: push-feed handshake and sweep against a provider no longer configured (#36608)

Regression tests that fail on main: a cookie handshake for a session issued by a
provider that is no longer configured is accepted (SocketAddressFilterTest,
SessionMultiNodeIT), and the socket sweep keeps such sockets open
(WebSocketManagerTest).

* Fixes #36608: close push-feed sockets when the authentication provider changes

Push-feed sockets ignored the rule that a session issued by a provider that is
no longer configured stops working:

- The cookie handshake (SocketAddressFilter.validateSessionStillActive) and the
  60 s socket sweep (WebSocketManager.isSessionActiveForUser) never checked the
  session's provider.
- Sockets opened with a provider token and no session (the default public-client
  SSO setup) are never re-checked at all, so they outlived the swap.

SessionProviders.isFromAnotherProvider is now the one predicate. JwtFilter,
refresh, the handshake and the sweep decide through it, and a security reload
that really changes the provider closes every socket on that server, with or
without a session. A basic/openmetadata rename closes nothing. Sockets are
closed; sessions are not revoked, as JwtFilter does not revoke them either.

Amends ADR 2026-10-20 (v2) and the session design doc (8.1, 8.4).

* Close a push-feed socket that registers after a provider switch (#36608)

The websocket transport validates the token on the upgrade, but the
socket only enters activityFeedEndpoints when the client's CONNECT
arrives a round trip later. A handshake validated under the old
provider just before a reload could register after disconnectAll and
survive the switch; the sweep skips it because it has no session.

The handshake now stamps the provider of the JwtFilter that validated
it (AuthProvider header, next to UserId/SessionId, on both transports).
The connection handler registers the socket first, then compares the
stamp with the configured provider and closes it on a mismatch. The
configuration is swapped before the reload closes sockets, so either
disconnectAll or the registration check catches it.

* Judge push-feed sockets against the provider the socket filter applied (#36608)

A security reload publishes its configuration, and hands it to
SessionService, before it initializes the new authenticator, and rolls
everything back if that fails. The registration check read the published
configuration and the sweep read SessionService's, so a Google-to-LDAP
save whose LDAP initialization then failed could close Google sockets
that the rolled-back server still accepts. The UI does not reconnect
after a server close, so those feeds stayed down.

Registration and the sweep now judge against
SocketAddressFilter.validatingProvider(). Only the reload listener
rebuilds that filter, and it runs only for a reload that succeeded.
WebSocketManager is built on it through
OpenMetadataApplication.buildPushFeedSockets. A real switch is still
caught either way: the socket registers before its check, and the
listener rebuilds the filter before disconnectAll.

The handshake's session check stays on SessionService: in that window
it answers 401, which the UI retries, as REST does then.

(cherry picked from commit 64141df)

Co-authored-by: deepinsight coder <32898216+Vamsi-klu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] WebSocket connections remain authorized after authentication provider swap (provider-currency check missing)

2 participants