-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added: Random Passwords #48
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather have user specify their format and split the char pools into named groups with single char alias that could be grouped in a map
A for uppercase letters
b (or a) for lowercase letters
0 for numbers
+ for symbols
x for anything
the same way I give a format for the username i could give :
xxxxxxxx for a 8 char full random password
AbbAbb0000+ for a 100 chars starting with 6 letters, then 4 numbers then a symbol
Also utility class wise the characters set should be able to be customized (no need to go up to the command line for that).
But as far as core could be used as a depency, I should be able to remove the symbols that cannot be typed easily in my language, avoir similar chars such as 0 and O.
Cool idea but not required :
One step further would be to use strings instead of chars, which would let me use phonetic words in order to make a password that can be said or remembered easily. Much like Japanese romanji does.
@@ -13,6 +13,7 @@ | |||
EMAIL("m", "mail", true, "account email address"), | |||
SINGLE_USERNAME("u", "username", true, "account username/login"), | |||
PASSWORD("p", "password", true, "account password"), | |||
PASSWORD_LENGTH("pl", "passwordLength", true, "random account password length"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options key should not overlap each other one should not start like the other.
"p" is contained in "pl"
|
||
private int length; | ||
|
||
public RandomPasswordGenerator(Integer length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to take an Integer as paramter, primitive int would be better to avoid null checks
@@ -106,22 +109,36 @@ private static Configuration updateConfiguration(Configuration config, Options o | |||
|
|||
// 3 types of generation : unique, csv and sequence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Password generator could also be used with csv input, if the password header is not added in file.
This could be part of another PR.
sequenceGenerator.setUsernamePattern(cmd.getOptionValue(CliOptions.SEQ_ACCOUNTS_FORMAT.shortName)); | ||
sequenceGenerator.setNbAccounts(Integer.parseInt(cmd.getOptionValue(CliOptions.SEQ_ACCOUNTS_COUNT.shortName))); | ||
sequenceGenerator.setStartFrom(Integer.parseInt(cmd.getOptionValue(CliOptions.SEQ_ACCOUNTS_START.shortName, "0"))); | ||
if (cmd.hasOption(CliOptions.PASSWORD.shortName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate code should be joined as one.
PasswordGenerator definition could be done before the "3 types of generation" fork
private static final int MIN_LENGTH = 8; | ||
private static final int MAX_LENGTH = 50; | ||
|
||
private static Logger LOGGER = LoggerFactory.getLogger(KinanCityCli.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On other classes I currently use instance loggers :
private Logger logger = LoggerFactory.getLogger(getClass());
LOGGER.warn("Password length must be a number! Using a random length!"); | ||
this.length = -1; | ||
} | ||
else if (length < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style : else if
should be on the same line then the closing bracket of previous if
|
||
data = generator.next(); | ||
assertThat(data).isNotNull(); | ||
assertThat(data.getUsername()).isEqualTo("pref01235suf"); | ||
assertThat(data.getPassword().length()).isBetween(8, 50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the same regexp or calling directly isAccountValid would be better.
How about not adding a now flag but adding these formats to the default password flag. Chars would only be replaced if the char is inside the char pool. So by defaults Passwordxxx stays Passwordxxx Config file default: |
@123FLO321 any chance you can finish the alterations requested by drallieiv? Having the ability to set a pattern for password generation is completely optional for me but it's a nice feature. |
@neskk Yes, I'll continue working on this soon. And I guess also implementing it into the username. |
It would definately be easier to have 2 distinct parameters for fixed password and random password. As for using "pwPool.i" properties file reading can only be done if the key is known |
@neskk I already explained myself on DM, username check is already implemented on the API but was removed from the process. If you want to put it back, create a separate pull request using it, and prove me wrong. |
@drallieiv I don't see any reason to have 2 separate password parameters since random pw/username would be disabled by default. |
@123FLO321 I think @drallieiv was thinking when you want to distinguish "pure random" from "pattern random" |
@neskk "-pw Password+" would not be replaced by default. |
@123FLO321 ah ok I think I understood now... what you mean is that these three options exist, right?
I think it would be cool if username could use the same logic as password to generate random usernames. |
@neskk No only 2 (+pool) new ones: enable random password and enable random username. |
Agree with @neskk that random usernames are needed also to avoid Niantic detection from looking for patterns in future. Currently I am creating random usernames/passwords in excel and importing them into KinanCity. |
If anyone wants to work on that, let me know |
added random passwords if no password is specified (for Sequence and Single)
added "pl" flag to specify length of random passwords (defaults: random)