Skip to content
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

Secure create-user command #127

Merged
merged 6 commits into from
Feb 10, 2018
Merged

Secure create-user command #127

merged 6 commits into from
Feb 10, 2018

Conversation

simonschaufi
Copy link
Contributor

Ask the user for the password

Fixes #123

Ask the user for the password

Fixes #123
@simonschaufi
Copy link
Contributor Author

Do you want to have an option to pass the password as parameter? Imho this could only be useful for demo installation or so...

@kevinpapst
Copy link
Member

Yes please, an additional option for automated installer would be great :-)

Copy link
Member

@kevinpapst kevinpapst left a comment

Choose a reason for hiding this comment

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

Please add an option to pass it via command line (for script based installations)

@@ -79,9 +79,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);

/* @var \Symfony\Component\Console\Helper\QuestionHelper $helper */
Copy link
Member

Choose a reason for hiding this comment

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

Please extract this part as method - e.g protected function askForPassword()

@simonschaufi
Copy link
Contributor Author

ready to merge

@kimai kimai deleted a comment from kevinpapst Feb 10, 2018
@kimai kimai deleted a comment from kevinpapst Feb 10, 2018
$helper = $this->getHelper('question');

$passwordQuestion = new Question('Please enter the password');
$passwordQuestion->setHidden(true);
Copy link
Member

Choose a reason for hiding this comment

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

Either we add a repeat question or we display the password. Otherwise its to easy to accidentaly create a user with a wrong password.

Copy link
Contributor Author

@simonschaufi simonschaufi Feb 10, 2018

Choose a reason for hiding this comment

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

using mysqldump works the same way. I'm against it. you can enter 3 times an empty password until it stops.

Copy link
Member

Choose a reason for hiding this comment

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

Then lets leave it for now, can still be improved if user complain

README.md Outdated
@@ -118,7 +118,7 @@ bin/console cache:warmup --env=prod
Create your first user:

```bash
bin/console kimai:create-user username password [email protected] ROLE_SUPER_ADMIN
bin/console kimai:create-user username [email protected] ROLE_SUPER_ADMIN
Copy link
Member

Choose a reason for hiding this comment

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

+bin/console kimai:create-user username [email protected] ROLE_SUPER_ADMIN password

Either you can enter the password as optional last argument or you can enter it interactively for protecting your bash history

Copy link
Contributor Author

@simonschaufi simonschaufi Feb 10, 2018

Choose a reason for hiding this comment

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

I would prefer not to write that in the Readme but in the full documentation. We don't want to encourage people for the first install to append it. For most of the people its just for the installation. then they will continue adding new users via the admin panel anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Fine for me, but currently there is nothing documented. Then don't add the last argument but add a sentence that the user is asked for the password.

->addArgument('username', InputArgument::REQUIRED, 'The username of the user to be created (must be unique)')
->addArgument('email', InputArgument::REQUIRED, 'Email address of the user to be created (must be unique)')
->addArgument('role', InputArgument::OPTIONAL, 'A comma separated list of roles to assign. Examples: "ROLE_USER,ROLE_SUPER_ADMIN"', User::DEFAULT_ROLE)
->addArgument('password', InputArgument::OPTIONAL, 'Password of the user to be created')
Copy link
Member

Choose a reason for hiding this comment

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

Password for the new user

@@ -115,16 +115,16 @@
},
{
"name": "beberlei/DoctrineExtensions",
"version": "v1.0.20",
"version": "v1.0.21",
Copy link
Member

Choose a reason for hiding this comment

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

Why did you run composer update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not? if something breaks, I don't want to be responsible for that.

Copy link
Member

Choose a reason for hiding this comment

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

I am against composer update during some random PR. Even though most of the packages have trusted developers behind them and use proper semver versioning, there is still a risk in upgrading packages without retesting the complete app.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so when is the best time to do it? since we have unit tests, we should know when something breaks.

Copy link
Member

Choose a reason for hiding this comment

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

with the current state of the unit tests, there is not a lot of trust. too many tests are using - btw. i will add a test to this PR later

again, lets leave it for now, but we should be careful later on when the app is in use

kevinpapst
kevinpapst previously approved these changes Feb 10, 2018
@kevinpapst
Copy link
Member

Wanna check my commit?


protected function createUser($username, $email, $role, $password)
{

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove empty line


$command = $this->application->find('kimai:create-user');
$commandTester = new CommandTester($command);
$commandTester->execute(array(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use short array syntax

if (trim($value) == '') {
throw new \Exception('The password cannot be empty');
$password = trim($value);
if (empty($password) || strlen($password) < 6) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldn't we require not at least 8 chars? Well, it has to be in sync as creating users via the admin interface.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't know. Its the same as in the entity right now. I am not sure if we should force users to use a strong password, which they will then just stick to their monitor ;-)

Copy link
Member

@kevinpapst kevinpapst left a comment

Choose a reason for hiding this comment

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

Approved, thanks!

@kevinpapst kevinpapst merged commit 93e1cd5 into master Feb 10, 2018
@kevinpapst kevinpapst deleted the secure-user-command branch February 10, 2018 18:11
@kevinpapst kevinpapst added this to the 0.2 milestone Jun 23, 2018
@lock
Copy link

lock bot commented Nov 18, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Nov 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants