public static function getCommandDescription(): string
{
return 'Creates a new security user class';
}
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the security user class (e.g. <fg=yellow>User</>)')
->addOption('is-entity', null, InputOption::VALUE_NONE, 'Do you want to store user data in the database (via Doctrine)?')
->addOption('identity-property-name', null, InputOption::VALUE_REQUIRED, 'Enter a property name that will be the unique "display" name for the user (e.g. <comment>email, username, uuid</comment>)')
->addOption('with-password', null, InputOption::VALUE_NONE, 'Will this app be responsible for checking the password? Choose <comment>No</comment> if the password is actually checked by some other system (e.g. a single sign-on server)')
->addOption('use-argon2', null, InputOption::VALUE_NONE, 'Use the Argon2i password encoder? (deprecated)')
$missingPackagesMessage = $dependencies->getMissingPackagesMessage(self::getCommandName(), 'Doctrine must be installed to store user data in the database');
if ($missingPackagesMessage) {
throw new RuntimeCommandException($missingPackagesMessage);
}
}
$input->setOption('is-entity', $userIsEntity);
$identityFieldName = $io->ask('Enter a property name that will be the unique "display" name for the user (e.g. <comment>email, username, uuid</comment>)', 'email', [Validator::class, 'validatePropertyName']);
$io->text('Will this app need to hash/check user passwords? Choose <comment>No</comment> if passwords are not needed or will be checked/hashed by some other system (e.g. a single sign-on server).');
$userWillHavePassword = $io->confirm('Does this app need to hash/check user passwords?');
$nextSteps[] = "Your <info>security.yaml</info> could not be updated automatically. You'll need to add the following config manually:\n\n".$yamlExample;
}
$nextSteps[] = 'Create a way to authenticate! See https://symfony.com/doc/current/security.html';
$nextSteps = array_map(function ($step) {
return sprintf(' - %s', $step);
}, $nextSteps);
$io->text($nextSteps);
}
public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void
{
// checking for SecurityBundle guarantees security.yaml is present
$dependencies->addClassDependency(
SecurityBundle::class,
'security'
);
// needed to update the YAML files
$dependencies->addClassDependency(
Yaml::class,
'yaml'
);
if (null !== $input && $input->getOption('is-entity')) {