Repository navigation
[SYNCOPE-2010] DefaultPasswordGenerator.merge() ignores usernameAllowed - #1606
Conversation
|
Hi @gianpaolo-pestilli thanks for this PR. |
|
@gianpaolo-pestilli I was able to verify this issue. |
|
I went ahead and created https://issues.apache.org/jira/browse/SYNCOPE-2010 |
|
Hi @ilgrosso, and sorry for the late reply. I have just pushed a new commit with the requested changes: I added tests for the other combinations: with the fix applied, all of them pass. Thank you for verifying the issue. I was waiting to reply because I don’t have a JIRA account yet. Regarding the ICLA, I haven’t submitted it yet: this is my first contribution to an open source project and I wasn’t sure about it. I’m going to look into it and will let you know here. Thanks for your patience and your help! |
|
@gianpaolo-pestilli the PR looks good now. |
|
Thanks @ilgrosso! I have just sent my signed ICLA: please let me know if there’s anything else I should do. |
|
Thank you very much @gianpaolo-pestilli ! |
Problem
DefaultPasswordGenerator.merge(List<DefaultPasswordRuleConf>)always returnsa configuration with
usernameAllowed == true, even when every inputconfiguration has
usernameAllowed == false.How to reproduce
The test added in this PR fails on current
masterwithout the fix:Cause
In
merge,resultis initialized withresult.setUsernameAllowed(true)and is never set to
falsebefore the following checksyncope/core/spring/src/main/java/org/apache/syncope/core/spring/security/DefaultPasswordGenerator.java
Lines 153 to 155 in 193c94e
The condition can therefore never be true, and the value of
usernameAllowedin the input configurations is never read.Proposed fix
Remove the negation, so that
usernameAllowedstaystrueonly if all theconfigurations allow it (consistently with the other fields, where the most
restrictive value wins):
Tests
Added
PasswordGeneratorTest.allForbid(): withtwo configurations both having
usernameAllowed == false,merge()mustreturn
usernameAllowed == false. It fails without the fix and passes with it.Note
If the current behavior is intended, please let me know and I will adjust
or close this PR.
cc @gulyx