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 |
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.