fix(sessions): keep the core session for native logout on /qqq/v1/logout #31
Open
james.maes
wants to merge 2 commits from
fix/logout-keep-core-session-for-native-logout into develop
pull from: fix/logout-keep-core-session-for-native-logout
merge into: QRun-IO:develop
QRun-IO:develop
QRun-IO:release/0.5
QRun-IO:release/0.1
QRun-IO:kof22/release-0.1-reactor
QRun-IO:kof22/scanners-reactor
QRun-IO:fix/refresh-device-versions
QRun-IO:feat/echo-forge-delta-20261106
QRun-IO:fix/approved-scanner-photo-availability
QRun-IO:fix/demo-object-store-integrity
QRun-IO:feature/kof22-scanners-postgres
QRun-IO:feature/gs1-echo-record-photos
QRun-IO:ci/enable-scanner-snapshots
QRun-IO:feature/echo-example
QRun-IO:main
QRun-IO:archive/qrun-github-cutover-20261101/bbc1fbf0808e/feature/echo-example
QRun-IO:archive/qrun-github-cutover-20261101/b156ab7c50e0/fix/authentication-metadata-device-headers
QRun-IO:fix/authentication-metadata-device-headers
QRun-IO:dependabot/maven/demo/develop/org.junit.jupiter-junit-jupiter-6.1.3
QRun-IO:dependabot/maven/demo/develop/com.kingsrook.qqq-qqq-frontend-next-1.0.0-RC.37
QRun-IO:dependabot/maven/develop/org.junit.jupiter-junit-jupiter-6.1.3
QRun-IO:dependabot/maven/develop/maven-minor-and-patch-24c72ca1f1
QRun-IO:dependabot/github_actions/develop/github-actions-9fad275170
No Reviewers
Labels
Clear labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
secuurity
wontfix
Something isn't working
Improvements or additions to documentation
This issue or pull request already exists
New feature or request
Pull requests that update GitHub Actions code
Good for newcomers
Extra attention is needed
This doesn't seem right
Pull requests that update java code
Further information is requested
This will not be worked on
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: QRun-IO/qbit-mobile-scanners#31
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
Confirmed on a physical MC9400 with the production 1.0.2 APK against a real Authentik fixture: company sign-out (RP-initiated provider logout) never received
nativeLogoutDatafromPOST /qqq/v1/logout {"nativeLogout":{"postLogoutRedirectUri":...}}while the device had an active mobile session. A plain HTTP client without a mobile session binding received the full logout data, so the core path itself was fine.Cause:
MobileScannersRouteProvider.bindDevicespecial-cases/qqq/v1/logoutand calledMobileSessionService.recordLogout()before the core handler. That ranend(..., "SIGN_OUT", false)->cleanupAuthentication(...), which executed the coreLogoutExecutor(without the native callback) andQSessionStoreHelper.removeSession(coreUuid). When the coreLogoutSpecV1.buildInputthen ran,ExecutorSessionUtils.setupSessionfailed (session already gone),nativePostLogoutRedirectUriwas never set, and nonativeLogoutDatawas returned.Change
MobileSessionService.recordLogout()now ends the mobile session with a new private overloadend(id, reason, administrator, coreLogoutFollows). WithcoreLogoutFollows, the row is tombstoned as before (ENDED,endReason SIGN_OUT, screens removed,screenAvailable/foregroundfalse) andauthCleanupStatusis set toDELEGATED(withauthCleanupAt) instead of runningcleanupAuthentication. The core/qqq/v1/logouthandler that follows in the same request prepares native logout data from the still-valid core session and then performs the provider logout and session removal.endCurrent(/sessions/current/end), administrator ends and the bulk End Session process are unchanged: they still runcleanupAuthentication(REQUESTED/RETRY_NEEDED)./qqq/v1/logoutpre-handler keeps its tolerant try/catch: an unbound or invalid session still reaches the core handler.docs/OPERATIONS.md(cleanup statuses now listDELEGATED) and one entry indocs/SESSION-STATE.md. No OpenAPI contract change; the extension version is not bumped.Tests (base module)
Three focused tests in
MobileScannersTestdrive the real route chain in an in-process Javalin server (scannerbefore("/qqq/*")pre-handler, then the coreLogoutSpecV1), using a recording authentication module (QAuthenticationType.CUSTOMextending the mock module) and a recording core session store:coreLogoutWithNativeLogoutKeepsCoreSessionUntilCoreHandlerRuns: withnativeLogoutin the body, the core session is still present and nothing has been removed or logged out when the core handler starts; afterwards the provider logout ran exactly once, the store is empty, and the mobile row isENDED/SIGN_OUT/DELEGATED.endCurrentStillPerformsCoreLogout:/sessions/current/endstill runs the core logout itself (REQUESTED).plainCoreLogoutEndsMobileRowAndCoreSessionOnce: a body-less logout ends both the mobile row and the core session exactly once, and a second logout with an unbound cookie still reaches the core handler.The harness cannot configure a real OAuth2 provider with native logout, so the tests assert the precondition the core handler needs (core session intact when it starts) rather than the
nativeLogoutDatapayload itself; a device rerun against Authentik with a build containing this fix is still needed.mvnw -o -pl base verify: 59 tests, 0 failures/errors/skips, 0 Checkstyle violations.🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.