{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/167435448","pull_request_review_id":95656201,"id":167435448,"diff_hunk":"@@ -0,0 +1,94 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Symfony\\Bundle\\FrameworkBundle\\Form;\n+\n+use Symfony\\Bundle\\SecurityBundle\\Security\\FirewallMap;\n+use Symfony\\Component\\Form\\AbstractType;\n+use Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType;\n+use Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType;\n+use Symfony\\Component\\Form\\FormBuilderInterface;\n+use Symfony\\Component\\Form\\FormError;\n+use Symfony\\Component\\Form\\FormEvent;\n+use Symfony\\Component\\Form\\FormEvents;\n+use Symfony\\Component\\HttpFoundation\\RequestStack;\n+use Symfony\\Component\\OptionsResolver\\OptionsResolver;\n+use Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\n+use Symfony\\Component\\Security\\Http\\Authentication\\AuthenticationUtils;\n+use Symfony\\Component\\Translation\\TranslatorInterface;\n+\n+class LoginType extends AbstractType\n+{\n+    private $requestStack;\n+    private $firewallMap;\n+    private $authenticationUtils;\n+    private $urlGenerator;\n+    /**\n+     * @var TranslatorInterface\n+     */\n+    private $translator;\n+\n+    public function __construct(RequestStack $requestStack, FirewallMap $firewallMap, AuthenticationUtils $authenticationUtils, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator)\n+    {\n+        $this->requestStack = $requestStack;\n+        $this->firewallMap = $firewallMap;\n+        $this->authenticationUtils = $authenticationUtils;\n+        $this->urlGenerator = $urlGenerator;\n+        $this->translator = $translator;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function buildForm(FormBuilderInterface $builder, array $options)\n+    {\n+        $firewallConfig = $this->firewallMap->getFirewallConfig($this->requestStack->getCurrentRequest());\n+        if (!$firewallConfig || !$firewallConfig->isSecurityEnabled()) {\n+            throw new \\LogicException('You cannot use LoginType if security is not enabled');\n+        }\n+\n+        $firewallOptions = $firewallConfig->getOptions()['form_login'];","path":"src/Symfony/Bundle/FrameworkBundle/Form/LoginType.php","position":58,"original_position":58,"commit_id":"2505144ab3ea5417ed75489fd347f07ed79fa77d","original_commit_id":"2505144ab3ea5417ed75489fd347f07ed79fa77d","user":{"login":"Koc","id":191082,"avatar_url":"https://avatars1.githubusercontent.com/u/191082?v=4","gravatar_id":"","url":"https://api.github.com/users/Koc","html_url":"https://github.com/Koc","followers_url":"https://api.github.com/users/Koc/followers","following_url":"https://api.github.com/users/Koc/following{/other_user}","gists_url":"https://api.github.com/users/Koc/gists{/gist_id}","starred_url":"https://api.github.com/users/Koc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koc/subscriptions","organizations_url":"https://api.github.com/users/Koc/orgs","repos_url":"https://api.github.com/users/Koc/repos","events_url":"https://api.github.com/users/Koc/events{/privacy}","received_events_url":"https://api.github.com/users/Koc/received_events","type":"User","site_admin":false},"body":"Is it safe read this key? IMHO we can get undefined index when `form_login` not defined in current firewall.","created_at":"2018-02-11T13:49:52Z","updated_at":"2018-02-11T13:49:52Z","html_url":"https://github.com/symfony/symfony/pull/26135#discussion_r167435448","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/26135","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/167435448"},"html":{"href":"https://github.com/symfony/symfony/pull/26135#discussion_r167435448"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26135"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/26135","id":168414590,"html_url":"https://github.com/symfony/symfony/pull/26135","diff_url":"https://github.com/symfony/symfony/pull/26135.diff","patch_url":"https://github.com/symfony/symfony/pull/26135.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/26135","number":26135,"state":"open","locked":false,"title":"[FrameworkBundle] [SecurityBundle][WIP] Added LoginType","user":{"login":"B-Galati","id":895123,"avatar_url":"https://avatars3.githubusercontent.com/u/895123?v=4","gravatar_id":"","url":"https://api.github.com/users/B-Galati","html_url":"https://github.com/B-Galati","followers_url":"https://api.github.com/users/B-Galati/followers","following_url":"https://api.github.com/users/B-Galati/following{/other_user}","gists_url":"https://api.github.com/users/B-Galati/gists{/gist_id}","starred_url":"https://api.github.com/users/B-Galati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B-Galati/subscriptions","organizations_url":"https://api.github.com/users/B-Galati/orgs","repos_url":"https://api.github.com/users/B-Galati/repos","events_url":"https://api.github.com/users/B-Galati/events{/privacy}","received_events_url":"https://api.github.com/users/B-Galati/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | master\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | no\r\n| License       | MIT\r\n| Doc PR        | TODO\r\n\r\n- [ ] update changelog\r\n- [ ] update doc\r\n- [ ] manage simple_form\r\n\r\nHello,\r\n\r\nHere is a proposal to improve DX for the [login form](https://symfony.com/doc/current/security/form_login_setup.html) :\r\n\r\n- Template file would use the `form` function\r\n  - No need to bother with action, input name, translator\r\n- Controller only requires to create a form \r\n  - No need to call the AuthenticationUtils anymore\r\n- CSRF is rendered with the FormType\r\n  - No need to take care of this in the template\r\n\r\nI have a concrete (working) example with symfony-demo [here](https://github.com/B-Galati/demo/commit/8bb25da6800c618e6d9d08144d4c2a8948199884).\r\n\r\nThis PR is a POC/draft at the moment to concretely show what I would like to do. If the idea is accepted I will update the PR.\r\n\r\nLet me know what you all think. Perhaps it is a terrible idea for some reasons :D\r\n\r\nNote 1 : At the same time we could also add more information in the \"Security Firewall\" section of the profiler.\r\nNote 2 : If someone have an idea to make the LoginType secure by default when the CSRF is loaded it would be amazing.\r\nNote 3 : I took some ideas from \\Symfony\\Bundle\\SecurityBundle\\Tests\\Functional\\Bundle\\CsrfFormLoginBundle\\Form\\UserLoginType","created_at":"2018-02-10T18:36:55Z","updated_at":"2018-02-11T13:49:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0b4a1092b1104ce464db4d4b88490466df9427b5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":100378,"url":"https://api.github.com/repos/symfony/symfony/labels/Feature","name":"Feature","color":"02e10c","default":false},{"id":148416,"url":"https://api.github.com/repos/symfony/symfony/labels/FrameworkBundle","name":"FrameworkBundle","color":"DDDDDD","default":false},{"id":83934034,"url":"https://api.github.com/repos/symfony/symfony/labels/RFC","name":"RFC","color":"fbca04","default":false},{"id":58752396,"url":"https://api.github.com/repos/symfony/symfony/labels/SecurityBundle","name":"SecurityBundle","color":"DDDDDD","default":false},{"id":237003792,"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Review","name":"Status: Needs Review","color":"ededed","default":false}],"milestone":{"url":"https://api.github.com/repos/symfony/symfony/milestones/17","html_url":"https://github.com/symfony/symfony/milestone/17","labels_url":"https://api.github.com/repos/symfony/symfony/milestones/17/labels","id":2795131,"number":17,"title":"4.1","description":"https://symfony.com/roadmap?version=4.1#checker","creator":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"open_issues":131,"closed_issues":136,"state":"open","created_at":"2017-09-26T15:40:00Z","updated_at":"2018-02-11T11:30:40Z","due_on":"2018-05-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/26135/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/26135/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/26135/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/2505144ab3ea5417ed75489fd347f07ed79fa77d","head":{"label":"B-Galati:login-form-type","ref":"login-form-type","sha":"2505144ab3ea5417ed75489fd347f07ed79fa77d","user":{"login":"B-Galati","id":895123,"avatar_url":"https://avatars3.githubusercontent.com/u/895123?v=4","gravatar_id":"","url":"https://api.github.com/users/B-Galati","html_url":"https://github.com/B-Galati","followers_url":"https://api.github.com/users/B-Galati/followers","following_url":"https://api.github.com/users/B-Galati/following{/other_user}","gists_url":"https://api.github.com/users/B-Galati/gists{/gist_id}","starred_url":"https://api.github.com/users/B-Galati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B-Galati/subscriptions","organizations_url":"https://api.github.com/users/B-Galati/orgs","repos_url":"https://api.github.com/users/B-Galati/repos","events_url":"https://api.github.com/users/B-Galati/events{/privacy}","received_events_url":"https://api.github.com/users/B-Galati/received_events","type":"User","site_admin":false},"repo":{"id":115867199,"name":"symfony","full_name":"B-Galati/symfony","owner":{"login":"B-Galati","id":895123,"avatar_url":"https://avatars3.githubusercontent.com/u/895123?v=4","gravatar_id":"","url":"https://api.github.com/users/B-Galati","html_url":"https://github.com/B-Galati","followers_url":"https://api.github.com/users/B-Galati/followers","following_url":"https://api.github.com/users/B-Galati/following{/other_user}","gists_url":"https://api.github.com/users/B-Galati/gists{/gist_id}","starred_url":"https://api.github.com/users/B-Galati/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B-Galati/subscriptions","organizations_url":"https://api.github.com/users/B-Galati/orgs","repos_url":"https://api.github.com/users/B-Galati/repos","events_url":"https://api.github.com/users/B-Galati/events{/privacy}","received_events_url":"https://api.github.com/users/B-Galati/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/B-Galati/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/B-Galati/symfony","forks_url":"https://api.github.com/repos/B-Galati/symfony/forks","keys_url":"https://api.github.com/repos/B-Galati/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/B-Galati/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/B-Galati/symfony/teams","hooks_url":"https://api.github.com/repos/B-Galati/symfony/hooks","issue_events_url":"https://api.github.com/repos/B-Galati/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/B-Galati/symfony/events","assignees_url":"https://api.github.com/repos/B-Galati/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/B-Galati/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/B-Galati/symfony/tags","blobs_url":"https://api.github.com/repos/B-Galati/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/B-Galati/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/B-Galati/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/B-Galati/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/B-Galati/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/B-Galati/symfony/languages","stargazers_url":"https://api.github.com/repos/B-Galati/symfony/stargazers","contributors_url":"https://api.github.com/repos/B-Galati/symfony/contributors","subscribers_url":"https://api.github.com/repos/B-Galati/symfony/subscribers","subscription_url":"https://api.github.com/repos/B-Galati/symfony/subscription","commits_url":"https://api.github.com/repos/B-Galati/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/B-Galati/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/B-Galati/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/B-Galati/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/B-Galati/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/B-Galati/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/B-Galati/symfony/merges","archive_url":"https://api.github.com/repos/B-Galati/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/B-Galati/symfony/downloads","issues_url":"https://api.github.com/repos/B-Galati/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/B-Galati/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/B-Galati/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/B-Galati/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/B-Galati/symfony/labels{/name}","releases_url":"https://api.github.com/repos/B-Galati/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/B-Galati/symfony/deployments","created_at":"2017-12-31T14:21:53Z","updated_at":"2017-12-31T14:22:11Z","pushed_at":"2018-02-10T18:31:07Z","git_url":"git://github.com/B-Galati/symfony.git","ssh_url":"git@github.com:B-Galati/symfony.git","clone_url":"https://github.com/B-Galati/symfony.git","svn_url":"https://github.com/B-Galati/symfony","homepage":"symfony.com","size":107862,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:master","ref":"master","sha":"3ef76bfc0b24df72940b1691617844d5e829b33f","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony/deployments","created_at":"2010-01-04T14:21:21Z","updated_at":"2018-02-11T12:55:52Z","pushed_at":"2018-02-11T12:12:20Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":113565,"stargazers_count":16577,"watchers_count":16577,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":6001,"mirror_url":null,"archived":false,"open_issues_count":839,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":6001,"open_issues":839,"watchers":16577,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26135"},"html":{"href":"https://github.com/symfony/symfony/pull/26135"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/26135"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/26135/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26135/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26135/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/2505144ab3ea5417ed75489fd347f07ed79fa77d"}},"author_association":"NONE"}}
{"actor":{"display_login":"Koc"}}