Skip to content

server: skip password policies check on empty password - #8370

Merged
shwstppr merged 2 commits into
apache:4.18from
scclouds:change-password-regex-default
Dec 22, 2023
Merged

shwstppr merged 2 commits into
apache:4.18from
scclouds:change-password-regex-default

Conversation

@JoaoJandre

Copy link
Copy Markdown
Contributor

Description

This PR changes the password.policy.regex default value to empty. With an empty value for the configuration, it is skipped during the password policy check, only when the configuration is set to something different than a blank string, the regex will get checked.
This way, when creating a user on org.apache.cloudstack.ldap.LdapAuthenticator#authenticate() we won't get an error by default, as a empty value for the password is passed.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

@JoaoJandre

Copy link
Copy Markdown
Contributor Author

I'm not sure if this is significant enough for 4.19, if not, I can target 4.18.2.

@shwstppr

Copy link
Copy Markdown
Contributor

@JoaoJandre would be good to fix in 4.18 branch but it seems it needs a DB change in the upgrade path. Not sure if it is desired at this point to have a 4181to4182 upgrade path

@codecov

codecov Bot commented Dec 18, 2023 •

Copy link
Copy Markdown

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (9d3a7be) 13.12% compared to head (e8b74f7) 30.65%.
Report is 1 commits behind head on 4.18.

Files Patch % Lines
...c/main/java/com/cloud/user/PasswordPolicyImpl.java 50.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               4.18    #8370       +/-   ##
=============================================
+ Coverage     13.12%   30.65%   +17.52%     
- Complexity     9141    33788    +24647     
=============================================
  Files          2720     5341     +2621     
  Lines        257723   374864   +117141     
  Branches      40177    54518    +14341     
=============================================
+ Hits          33838   114905    +81067     
- Misses       219595   244804    +25209     
- Partials       4290    15155    +10865     
Flag Coverage Δ
simulator-marvin-tests 24.42% <0.00%> (?)
uitests 4.39% <ø> (?)
unit-tests 16.46% <50.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DaanHoogland

Copy link
Copy Markdown
Contributor

is it wise to allow for empty passwords? I may be misinterpreting this code, but I would not want this in a default install. Or is this only applicable for LDAP logins?

BTW, the update is not necessary if the workaround is mentioned in the release notes. To my knowledge this fix is directed only at installations using LDAP, as mentioned in https://lists.apache.org/thread/tqtcwsfb0knmvqct1hlow4ty2nc2w2j2, is it?

these are questions/discussion points, no comments on the code.

@JoaoJandre

Copy link
Copy Markdown
Contributor Author

is it wise to allow for empty passwords? I may be misinterpreting this code, but I would not want this in a default install. Or is this only applicable for LDAP logins?

As the password is a required field when creating users using createAccount and createUser APIs, blank passwords are not allowed. Furthermore, on the updateUser API the password we check if the password is blank as well. The password policies were created on #6567 with the intention of being optional to keep backwards compatibility; therefore, I'd say that it makes sense to not block the operation using the default regex.

BTW, the update is not necessary if the workaround is mentioned in the release notes. To my knowledge this fix is directed only at installations using LDAP, as mentioned in https://lists.apache.org/thread/tqtcwsfb0knmvqct1hlow4ty2nc2w2j2, is it?

Yes this fix is directed only on installations using LDAP, from the code inspection that I did, the only instance of an empty password is on that method I mentioned on the description, the rest of the code will not allow a password that does not have at least one character.

Anyway, do you think that a note on the release notes is all that is needed on this case @DaanHoogland @weizhouapache @shwstppr ?

@weizhouapache

Copy link
Copy Markdown
Member

@JoaoJandre
can checks be skipped if source is User.Source.LDAP ?

@JoaoJandre

Copy link
Copy Markdown
Contributor Author

@JoaoJandre can checks be skipped if source is User.Source.LDAP ?

I'd rather keep the feature agnostic and avoid adding different workflows. If the consensus is that changing the configuration value is not the best solution, I'd rather either document the behavior, or change the call on org.apache.cloudstack.ldap.LdapAuthenticator#authenticate() to something that is not a blank string.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@JoaoJandre can checks be skipped if source is User.Source.LDAP ?

I'd rather keep the feature agnostic and avoid adding different workflows. If the consensus is that changing the configuration value is not the best solution, I'd rather either document the behavior, or change the call on org.apache.cloudstack.ldap.LdapAuthenticator#authenticate() to something that is not a blank string.

I agree, certainly if the LDAP autentication is the only one that suffers. I do not remember exactly how this works, but LDAP should put its own requirements on passwords.
see my dumb comment there ;)

        // TODO not allowing an empty password is a policy we shouldn't decide on. A private cloud may well want to allow this.
        if (StringUtils.isNoneEmpty(username, password)) {

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

@JoaoJandre
can you rebase with 4.18 ?

@JoaoJandre
JoaoJandre force-pushed the change-password-regex-default branch from e1d5604 to e8b74f7 Compare December 21, 2023 13:44
@JoaoJandre
JoaoJandre changed the base branch from main to 4.18 December 21, 2023 13:44
@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8120

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-8658)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 44933 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8370-t8658-kvm-centos7.zip
Smoke tests completed. 109 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@weizhouapache

Copy link
Copy Markdown
Member

testing result look ok

cc @shwstppr @DaanHoogland @JoaoJandre

@weizhouapache weizhouapache changed the title Change password.policy.regex default to empty server: skip password policies check on empty password Dec 22, 2023
@weizhouapache weizhouapache added this to the 4.18.2.0 milestone Dec 22, 2023

@shwstppr shwstppr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

@shwstppr
shwstppr merged commit 08749d8 into apache:4.18 Dec 22, 2023
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Dec 27, 2023
This PR changes the password.policy.regex default value to empty. With an empty value for the configuration, it is skipped during the password policy check, only when the configuration is set to something different than a blank string, the regex will get checked.
This way, when creating a user on org.apache.cloudstack.ldap.LdapAuthenticator#authenticate() we won't get an error by default, as an empty value for the password is passed.
shwstppr pushed a commit to shapeblue/cloudstack that referenced this pull request Apr 11, 2024
…pache#396)

This PR changes the password.policy.regex default value to empty. With an empty value for the configuration, it is skipped during the password policy check, only when the configuration is set to something different than a blank string, the regex will get checked.
This way, when creating a user on org.apache.cloudstack.ldap.LdapAuthenticator#authenticate() we won't get an error by default, as an empty value for the password is passed.

Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants