-
-
Notifications
You must be signed in to change notification settings - Fork 439
[make:security:json-login] WIP #1246
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
base: 1.x
Are you sure you want to change the base?
Conversation
4fe922a to
478077d
Compare
| '@Symfony' => true, | ||
| '@Symfony:risky' => true, | ||
| 'native_function_invocation' => false, | ||
| 'blank_line_before_statement' => ['statements' => ['break', 'case', 'continue', 'declare', 'default', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'phpdoc', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']], |
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.
we need phpdoc to be added... TODO: check whats included in symfony rules set and only add the one we need.
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.
im using our test config here because, well lazy is cool, but thinking we either duplicate this for generating templates or rename / move this away from "test" and still use it for both ci and generating templates. See CI failures related to other makers as a result of the added rule.
a692b79 to
8432cf1
Compare
|
|
||
| // last username entered by the user | ||
| /** last username entered by the user */ | ||
| $lastUsername = $authenticationUtils->getLastUsername(); |
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.
php-cs-fixer does not have the capability to add a space above a comments (//) but it can do it with docblocks (/** */)
Without changing the comments over, we would end up with:
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();which could be alright?
| $this->userNameField = $securityHelper->guessUserNameField($io, $this->userClass, $securityData['security']['providers']); | ||
| $this->willLogout = $io->confirm('Do you want to generate a \'/logout\' URL?'); | ||
| } | ||
| } |
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.
We could probably find more repeated code between make:json & make:form logins if we looked hard enough...
weaverryan
left a comment
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.
Looking great!
| 'Choose a name for the controller class (e.g. <fg=yellow>ApiLoginController</>)', | ||
| 'ApiLoginController', | ||
| [Validator::class, 'validateClassName'] | ||
| ); |
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.
This question and the suggestion of ApiLoginController are in the abstract security maker?
| public function configureDependencies(DependencyBuilder $dependencies): void | ||
| { | ||
| $dependencies->addClassDependency(SecurityBundle::class, 'security'); | ||
| $dependencies->addClassDependency(Process::class, 'process'); |
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.
Is this actually needed?
| 'use_statements' => $useStatements, | ||
| 'controller_name' => $controllerNameDetails->getShortName(), | ||
| ] | ||
| ); |
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.
This could be a new generateEmptyController() on Generator 🤔
| $this->writeSuccessMessage($io); | ||
|
|
||
| $io->text([ | ||
| 'Next: Make a <info>POST</info> request to <info>/api/login</info> with a <info>username</info> and <info>password</info> to login.', |
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.
The user also needs to set Content-Type: application/json iirc. This is sometimes a "gotcha", so it would be nice to mention it here.
| @@ -0,0 +1,11 @@ | |||
| <?php | |||
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.
The _L (capital L) looks weird, but I can see you did that on purpose. What was the reason?
|
|
||
| $this->addUseStatements($manipulator, [Route::class]); | ||
|
|
||
| $methodBuilder->addParam((new Param('authenticationUtils'))->setType('AuthenticationUtils')); |
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.
Will there already be a use statement for this? In addLoginMethod(), we explicitly add the use statement.
| (new Param('user')) | ||
| ->setType(new NullableType($userClass->getShortName())) | ||
| ->addAttribute(new Attribute(new Name('CurrentUser'))) | ||
| ); |
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.
This probably needs to change to $this->getUser() for better "portability" across all versions of Symfony, DoctrineBundle, FWEXtra, etc?
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.
Should we bother making that conditional based on the Symfony Version? Or perhaps we do that (CurrentUser) later when say 6.4 or 7 come out for less of a headache for us
96cc0d3 to
df01550
Compare
No description provided.