Repository navigation
Conversation
…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).
❌ PR checklist incompleteThis 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 |
Vamsi-klu
left a comment
There was a problem hiding this comment.
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.
- 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.
- nit, applied: on a switch the only log said "Force-disconnecting ... on session revocation". closeSocketsOnProviderSwitch now logs the previous and current provider first.
- 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.
- 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).
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Why these tests
Impacted, not run locally (13)
Commandsmvn -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 |
|
@Vamsi-klu one blocker before this can go in, the race greptile flagged at On the websocket transport the token is checked once, in Suggested fix: stamp the provider (or a reload generation counter) the handshake was validated under into the initial headers next to 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
left a comment
There was a problem hiding this comment.
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.
|
@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.
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. |
| AuthenticationConfiguration current = SecurityConfigurationManager.getCurrentAuthConfig(); | ||
| if (current == null | ||
| || !SessionProviders.isFromAnotherProvider(validatedProvider, current.getProvider())) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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)
|
@Vamsi-klu thanks for 2f8f1d6, it closes the CONNECT race I raised. Two things left:
|
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.
Code Review ✅ Approved 🔴 High riskProvider-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 ( VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
@yan-3005 thanks for checking it against 1. Greptile's P1. Agreed, it's real. The sweep had the same gap: The fix:
Tests:
I left the handshake's own session check on 2. CI. Merged the latest The local focused run on bf7dd8f is in the description: 235 unit tests across the 10 impacted classes and 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 |
yan-3005
left a comment
There was a problem hiding this comment.
Thanks @Vamsi-klu - Merging it
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
…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>
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). Onmainthere were three gaps:SocketAddressFilter.validateSessionStillActivechecked 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.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).OM_SESSIONcookie. 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
sessionIdclaim was already rejected, because the handshake runsJwtFilter.checkValidationsForToken, which callsvalidateSessionProviderIsCurrent. The exposed session path was the cookie.The fix makes
SessionProviders.isFromAnotherProviderthe 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. Abasic/openmetadatarename closes nothing.Type of change:
High-level design:
SessionProviders.isFromAnotherProvider(String, AuthProvider)isSameProvider.SessionService.isFromAnotherProvider(UserSession)JwtFilter.validateSessionProviderIsCurrentproviderType. No behavior change.SocketAddressFilter.validateSessionStillActiveWebSocketManager.isSessionActiveForUserWebSocketManager.disconnectAll(), andOpenMetadataApplication.pushFeedReloadListener, whichinitializeWebsocketsregisterscloseSocketsOnProviderSwitch(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.SocketAddressFilter.authenticatestamps anAuthProviderheader;WebSocketManager.onConnection(added in2f8f1d6)SocketAddressFilter.validatingProvider();WebSocketManagerbuilt on it throughOpenMetadataApplication.buildPushFeedSockets(added inbf7dd8f)SessionService's. Only the reload listener rebuilds the filter, and only for a reload that succeeded.Why each piece:
SessionServiceand the socket filter already hold the new configuration. A failed reload rolls back without notifying listeners, so nothing closes.disconnectAll, so whichever runs second catches it.reloadSecuritySystempublishes the new configuration, andreinitializeAuthSystemhands it toSessionService, 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 onSessionService: in that window it answers 401, which the UI retries, as REST does then.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).Rejected alternatives:
JwtFilter's guard into the socket sites: re-derives the check, which is how this bug happened.JwtFilter.validateSessionBoundToken: private, needs token claims, the sweep has noJwtFilter, and it acceptsREFRESHING.JwtFiltercallSessionService.isFromAnotherProvider: one request would be judged under two configuration snapshots, and candidate-configuration filters (TestLoginService,SystemRepository) would judge against the live configuration.Compatibility and rollout:
SessionProviders.isFromAnotherProvider,SessionService.isFromAnotherProvider(was private),WebSocketManager.disconnectAll,SocketAddressFilter.validatingProvider,WebSocketManagerBuilder.build(EngineIoServerOptions, Supplier<AuthProvider>)(the one-argumentbuildstays and applies no provider). No signature is removed or renamed.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., but the push feed validates under
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:
REFRESHINGsession as inactive while REST accepts it.Tests:
Use cases covered
Unit tests
SessionProvidersTest#isFromAnotherProvider_judgesOnlyAKnownSessionProviderAgainstAConfiguredOne(10 rows)SessionServiceTest#isFromAnotherProvider_followsTheConfigurationThisServerRunsNowSocketAddressFilterTest#cookieHandshakeIsRejectedWhenItsSessionsProviderIsNoLongerConfiguredSocketAddressFilterTest#cookieHandshakeAcceptsTheOtherNativePasswordProviderNameWebSocketManagerTest#disconnectInactiveSessions_closesSocketsWhoseSessionProviderIsNoLongerConfiguredWebSocketManagerTest#disconnectAll_closesSessionBoundAndSessionlessSocketsOpenMetadataApplicationAuthReloadTest#closeSocketsOnProviderSwitch_closesOnlyOnAProviderSwitch(4 rows)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).WebSocketManagerTest#onConnection_closesASocketValidatedUnderTheOldProviderThatRegistersAfterTheSwitch: the switch is made as a successful reload makes it (publish, then rebuild the filter, thendisconnectAll); the late Google sockets, sessionless and session-bound, close and the Azure one stays.WebSocketManagerTest#onConnection_keepsASocketValidatedUnderTheOtherNativePasswordProviderNameSocketAddressFilterTest#handshakeIsStampedWithTheProviderOfTheFilterThatValidatedIt(a client-sentAuthProviderheader is dropped)WebSocketManagerTest#onConnection_keepsASocketThatRegisteredDuringAReloadThatFailed: drives the realSecurityConfigurationManager.reloadSecuritySystem()(SettingsCachehands Google at boot and LDAP at the reload). WhilereinitializeAuthSystemruns, 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.WebSocketManagerTest#disconnectInactiveSessions_keepsSocketsWhileAReloadHasNotAppliedItsProvider:SessionServiceis handed LDAP while the filter still validates under Google; the Google session's socket stays.OpenMetadataApplicationAuthReloadTest#buildPushFeedSockets_sweepsAgainstTheProviderTheHandshakeFilterValidatesUnder: the managerinitializeWebsocketsbuilds follows its filter, notSessionService.SocketAddressFilterTest#validatingProviderNamesTheProviderTheFilterValidatesUnderT3 to T5 use a real
SessionServiceover a mockedSessionStore, and a realWebSocketManagerwith mockedSocketIoSockets. T10, T11, T13 to T15 build the manager on a realSocketAddressFilter(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):Mutation checks on the fix:
configuredProvider != nullguard in C1 fails T1 (NullPointerExceptionon thegoogle/null row).closeSocketsOnProviderSwitchfails T7's no-switch rows (run before the two unreachable null rows were removed).pushFeedReloadListener,getAndSet(current)replaced byget()fails T9 (the socket opened after the switch is closed by the next save); an empty initialAtomicReferencefails T9 with aNullPointerExceptionon the first reload.RED for the failed-reload window (
bf7dd8f's tests against the checks as they were at2f8f1d6):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 testwith jacoco, commit251b197), 10 classes:SessionProvidersTest13,SessionServiceTest46,SocketAddressFilterTest25,SocketAddressFilterSpoofRevalidationBypassTest3,WebSocketManagerTest14,JwtFilterTest106,Jetty12WebSocketHandlerTest7,OpenMetadataApplicationPushFeedUpgradeTest3,OpenMetadataApplicationAuthReloadTest10,OpenMetadataApplicationTest1. 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.pushFeedReloadListenerandcloseSocketsOnProviderSwitchare fully covered. The two uncovered lines are the arguments of the registration call ininitializeWebsockets, which runs only when a server boots (every IT node boots through it).OpenMetadataApplication,JwtFilterandSessionServicepredate this change, so changed-line coverage is reported instead.Backend integration tests
openmetadata-integration-tests/.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 togoogle; REST on B answers 401 (already true onmain); the handshake on B answers 401.T8 results:
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.SessionMultiNodeITclass throughmake java_affected_run, 12 run, 0 failed (T8 included), on93a803aand again on the final251b197(block below).93a803a(before the review amendment, which changed only the listener wiring inOpenMetadataApplicationand 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'spersistSessionhelper.Local Java test run: PASSED
bf7dd8fba493(baseorigin/main)--scope full).The run was
make java_affected_run ARGS='--scope focused --add-unit SocketAddressFilterSpoofRevalidationBypassTest,Jetty12WebSocketHandlerTest,OpenMetadataApplicationPushFeedUpgradeTest --reason "..."'; the three added classes exercise the handshake pathsSocketAddressFilterand 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
Playwright (UI) tests
Manual testing performed
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.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(thepr-checklistskill 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 in251b197(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. The93a803a..251b197delta 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-branchpasses).I have added a test that covers the exact scenario we are fixing (T3, T5 and T8 fail on
main).Fix the failed-reload disconnect before merging.
Findings
Summary
The PR makes push-feed connections follow authentication-provider changes.
Reviews (7) · Last reviewed commit: "Close a push-feed socket that registers ..." · Reviewed by Greptile