Repository navigation
feat: versioned (CAS) user writes in basic lock script - #15749
Conversation
Persist a locked:<millis> marker in the invalid-login count attribute and re-check it right before unlocking. Admin-disabled accounts stayed unlockable via an expired cache record, and a stale cache read could undo a concurrent re-lock. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
Unlock only when updatedAt still matches the lock write, so an admin disable during or after a lock survives a stale marker. Counter writes no longer overwrite a concurrent lock marker. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
Write the lock with merge and updatedAt equal to the marker time, so unlock needs an exact match instead of a 5 s slack that let a quick admin change through and a slow write lock forever. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
updateWithVersion with a null version expects the version attribute to be absent, so rows written before their class got @Version can use versioned updates without a backfill. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
Adds jansVersion to jansPerson and @Version to the auth-server and SCIM user entities, so every user merge bumps it. VM installs must add the column before upgrading (documented in database ops). Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
Lock, unlock and counter writes are compare-and-set on jansVersion and re-decide on a mismatch, closing the races left by plain merge. The lock marker records the version it writes so unlock rejects any later change. Falls back to merge on backends without versioned updates. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
config-api user JSON names the field status, not jansStatus: create ignored it and reads returned None, failing both lock behavior tests. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
Lock lasts 30 s in CI so the test can wait it out and log in again, exercising the marker and updatedAt round-trip on a real database. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
The unconditional write after repeated conflicts could store a version a concurrent writer also stored, so a lock and an admin write became indistinguishable to unlock. merge now throws VersionMismatchException after 10 conflicts and writes nothing. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com>
…at/basic-lock-cas Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> # Conflicts: # docs/script-catalog/person_authentication/basic-lock-account-external-authenticator/BasicLockAccountExternalAuthenticator.py # docs/script-catalog/person_authentication/other/basic.lock.account/README.md
|
|
|
|
|
|



Follow-up to #15743 (merged).
Closes residual races in the basic-lock script: plain
mergehad no compare-and-set, so concurrent lock/unlock/counter/admin writes could overwrite each other.updateWithVersionwith a null version matches only entries with no stored version (SQLIS NULL, LDAP(!(attr=*))); existing rows need no backfill.mergeon a@Versionentity writes with CAS on the version it read, re-reads on conflict, and on retry applies only the attributes the first read changed. After 10 conflicts it throwsVersionMismatchExceptionand writes nothing. Backends without versioned updates keep the plain write.jansVersionadded tojansPerson;@Versionon auth-serverUser(config-api, fido2), SCIMScimCustomPersonandUser, CasaBasePerson, Jans LinkUser. Equality unchanged; JSON output unchanged (@JsonIgnoreon auth-serverUser).registerFailedLogin); lock marker islocked:<ms>:<version>and unlock requires that version, never falling back to an unconditional write. A failure right after unlock uses the same counter path.install.py -upgradedoes not; run theALTER TABLEfrom the MySQL/PgSQL ops docs before starting new services. ManualUPDATEs onjansPersonmust advancejansVersion.jansVersionto thejansPersonobject class.Tests: ORM unit tests (73), auth common
UserServiceTest; Jython fake-store harness for lock, expiry unlock, admin write after lock, admin disable racing lock, parallel failures, admin edit racing unlock, threshold reset race, no-CAS fallback. Null-version predicate not run against live SQL/LDAP.