Skip to content

Bug 2005206 - OS session event detection + logout#422

Draft
gcp wants to merge 6 commits intoenterprise-mainfrom
os-session-event-detection
Draft

Bug 2005206 - OS session event detection + logout#422
gcp wants to merge 6 commits intoenterprise-mainfrom
os-session-event-detection

Conversation

@gcp
Copy link
Contributor

@gcp gcp commented Feb 10, 2026

No description provided.

@gcp gcp self-assigned this Feb 10, 2026
@gcp gcp changed the title WIP: OS session event detection + logout Bug 2005206 - OS session event detection + logout Feb 10, 2026
@gcp gcp force-pushed the os-session-event-detection branch 3 times, most recently from cc02111 to 16c8432 Compare February 13, 2026 14:00
gcp added 6 commits February 13, 2026 15:02
Define NS_WIDGET_OS_SESSION_END_OBSERVER_TOPIC,
NS_WIDGET_OS_USER_SWITCH_OBSERVER_TOPIC, and
NS_WIDGET_SCREEN_LOCKED_OBSERVER_TOPIC in nsIWidget.h, following the
existing pattern of sleep/wake observer topics.
Extend WinEventObserver to register for session notifications via
WTSRegisterSessionNotification, and fire screen-locked on
WTS_SESSION_LOCK and os-user-switch on WTS_CONSOLE_DISCONNECT.

Fire os-session-end in the WM_ENDSESSION handler in nsWindow.cpp
before the shutdown sequence begins, for logoff and OS shutdown events.
Register NSWorkspace notification observers in AppShellDelegate for
SessionDidResignActive (os-user-switch), WillPowerOff (os-session-end),
and ScreensDidSleep (screen-locked).

Fire os-session-end in MacApplicationDelegate's
applicationShouldTerminate: before quit-application-requested to catch
OS-initiated termination.
Extend DBusSessionSleepCallback to handle PrepareForShutdown signal
from login1.Manager, firing os-session-end.

Add login1.Session proxy to monitor the Active property for user
switching (os-user-switch), and org.freedesktop.ScreenSaver proxy to
listen for ActiveChanged signal (screen-locked).

The session proxy must be created on the real session object path
(e.g. /org/freedesktop/login1/session/_33) rather than the "auto"
convenience alias, because PropertiesChanged signals are only emitted
on the real path. When the login1 Manager proxy is ready, we resolve
the real path via GetSession(XDG_SESSION_ID) or GetSessionByPID as
a fallback, then create the session proxy on the resolved path.

Update DBusConnectClientResponse to dispatch by interface name to
support the new proxies alongside the existing ones.
New module that listens for os-session-end, os-user-switch, and
screen-locked observer topics and triggers the enterprise sign-out flow.

os-session-end always signs out. os-user-switch is controlled by the
enterprise.signoutOnUserSwitch pref (default: true). screen-locked is
controlled by the enterprise.signoutOnScreenLock pref (default: false).

The sign-out flow performs best-effort server-side token revocation
before clearing local tokens and handing off to FELT. The cleanup
steps are wrapped in try/finally to ensure quit() always executes.

Also add a .catch() handler to the rejected promise in
EnterpriseStorageManager.deleteAccountData() to prevent unhandled
rejection warnings during sign-out.
Integration tests covering all OS event scenarios: os-session-end
triggers signout unconditionally, os-user-switch respects pref,
screen-locked respects pref, and server-side logout is called.

Events are simulated via Services.obs.notifyObservers from chrome
context, exercising the full EnterpriseSessionObserver flow.
@gcp gcp force-pushed the os-session-event-detection branch from 16c8432 to 56b772c Compare February 13, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant