Repository navigation
server: fix NPE on first LDAP login - #14098
Conversation
Signed-off-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
|
hi @xujiantop-crypto can you rebase/change the target branch to 4.20 if the fix is relevant there. |
ignore this, the change is added in 4.23 (in this PR: #12294) |
|
@blueorangutan package |
|
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14098 +/- ##
=========================================
Coverage 19.79% 19.80%
- Complexity 20021 20023 +2
=========================================
Files 6371 6371
Lines 575954 575955 +1
Branches 70521 70522 +1
=========================================
+ Hits 114035 114056 +21
+ Misses 449483 449456 -27
- Partials 12436 12443 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the clarification. I will keep the target branch as |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19178 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-16961)
|
|
@RosiKyu , can you have a look at this? |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19843 |
RosiKyu
left a comment
There was a problem hiding this comment.
LGTM
Tested on a KVM env with the PR packages (cloudstack-management-24.0.0-shapeblue22383) and an OpenLDAP server; account linked with linkAccountToLdap type=GROUP accounttype=0, same steps as #14095:
- First login of an LDAP user, via the API and via the UI login page: user is created in the linked account and logged in, in one request, no NPE in the log. Later logins also work.
- Negative: wrong password, LDAP user outside the linked group, unknown user and wrong domain all get a clean 531 "Failed to authenticate".
- Regression: root admin and a native user in the LDAP-linked account log in as before.
Separate, not caused by this PR: a wrong-password login of an LDAP user in the linked group still creates that user in CloudStack (login fails with 531, but the user row is created). Will open an issue for it.
|
Awesome work, congrats on your first merged pull request! |
Description
On a user's first LDAP login,
getActiveUserAccountreturnsnullbeforeloginUserauthenticates the LDAP user and creates the CloudStack user. After the successful login, the OAuth login-detail cleanup dereferences that stalenullvalue and turns the successful login into an NPE.Only remove the OAuth login detail when the user already existed before authentication. A newly created LDAP user cannot have that pre-existing detail, so its successful login response is now returned normally.
Fixes #14095
Testing
Added
DefaultLoginAPIAuthenticatorCmdTest.testAuthenticateFirstLdapLoginWithoutExistingUserto reproduce the first-login flow and verify that OAuth-detail cleanup is skipped for a user that did not exist before LDAP authentication.Result: 1 test passed; all 26 reactor modules succeeded; Checkstyle reported 0 violations.