{"id":722,"date":"2021-06-29T14:37:56","date_gmt":"2021-06-29T13:37:56","guid":{"rendered":"http:\/\/blog.chen-hongyi.com\/?p=722"},"modified":"2021-07-01T06:57:55","modified_gmt":"2021-07-01T05:57:55","slug":"symfony-secutrity-%e4%b9%8b-auth-form-login-%e7%9a%84%e6%b5%81%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/chen-hongyi.com\/?p=722","title":{"rendered":"Symfony 5.2 Secutrity \u4e4b Auth Form Login \u7684\u6d41\u7a0b"},"content":{"rendered":"\n<p>AuthLog\u5c5e\u4e8esecurtiy\u6a21\u5757\uff0c\u914d\u7f6e\u6587\u4ef6\u662fsecurity.yaml\u6587\u4ef6\u3002\u914d\u7f6e\u4e2d\u4e3b\u8981\u7684key\u662f firewall.<\/p>\n\n\n\n<p>\u8d1f\u8d23Form\u767b\u9646\u9274\u5b9a\u7684\u7c7b\u4e3b\u8981\u662fLoginFormAuthenticator , \u5b9e\u73b0\u4e86 AuthenticatorInterface .<\/p>\n\n\n\n<p>\u5173\u4e8e\u51e0\u4e2a\u6982\u5ff5, \u53ef\u4ee5\u53c2\u8003<a href=\"http:\/\/www.hyhblog.cn\/2018\/04\/25\/user_login_auth_terms\/\">\u8fd9\u7bc7\u6587\u7ae0<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>authen-tication \u9274\u6743 (who are you?)<\/li><li>autho-rization \u6388\u6743 (what permission do you have?)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">AbstractFormLoginAuthenticator (\u4ee5\u4e0b\u7b80\u79f0AFA)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>AFA::<strong>supports<\/strong>($request $req) bool<br><em>Does the authenticator support the given Request?  If this returns false, the authenticator will be skipped.<\/em><br>\u7528\u6765\u5224\u65ad\u662f\u5426\u9700\u8981\u4f7f\u7528\u767b\u5f55\u9274\u5b9a<br><\/li><li>AFA::<strong>getCredentials<\/strong>(Request $req)::array<br>\u7528\u6765\u83b7\u53d6\u5ba2\u6237\u8f93\u5165\u7684\u767b\u5f55\u51ed\u8bc1(\u7528\u6237\u540d\u548c\u5bc6\u7801)\uff0c\u540c\u65f6\u628a\u7528\u6237\u7684\u6700\u540e\u4e00\u6b21\u8f93\u5165\u7684\u7528\u6237\u540d\u4fdd\u5b58\u5230session\u4e2d\uff0c\u5df2\u5907\u73b0\u5b9e\u9519\u8bef\u4fe1\u606f\u65f6\u4f7f\u7528<br><\/li><li>AFA::<strong>getUser<\/strong>($credentials, $userProvider): userInterface<br>\u4eceuserProvider\u83b7\u53d6\u7528\u6237\u6a21\u578b\u3002\u5982\u679c\u7528\u6237\u6ca1\u6709\u627e\u5230\u5462\uff1f<br><\/li><li>AFA::<strong>checkCredentials<\/strong>(credentials, user): bool<br>\u6bd4\u8f83credentials\u4e2d\u7684\u8f93\u5165\u5bc6\u7801\u548cuser\u4e2d\u4fdd\u5b58\u7684\u5bc6\u7801<br><\/li><li>AFA::<strong>onAuthenticationSuccess<\/strong>() <br>\u767b\u9646\u6210\u540e\u7684\u56de\u8c03\u51fd\u6570<br><\/li><li>AFA::<strong>onAuthenticationFailure<\/strong>($request, $exception)<br>\u767b\u9646\u5931\u8d25\u7684\u56de\u8c03\u51fd\u6570\u3002\u7528\u4e8e\u6bd4\u5982\u8bb0\u5f55\u5f02\u5e38\u7684\u4fe1\u606f\u5230session\u3002<br><\/li><li>AFA::<strong>getLoginUrl<\/strong>(): string<br>\u7528\u4e8e\u4f46\u767b\u9646\u5931\u8d25\uff0c\u9700\u8981\u628a\u7528\u6237\u91cd\u65b0\u5f15\u5230\u5230\u767b\u9646\u9875\u9762\u5730\u5740<br><\/li><\/ul>\n\n\n\n<p>\u5907\u6ce8: \u5b8c\u6210\u6587\u7ae0\u540e\u53d1\u73b0Symfony 5.3\u5bf9Auth\u505a\u4e86\u6539\u52a8\u3002\u6240\u4ee5\u8bf7\u6ce8\u610f\u7248\u672c\u3002 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>AuthLog\u5c5e\u4e8esecurtiy\u6a21\u5757\uff0c\u914d\u7f6e\u6587\u4ef6\u662fsecurity.yaml\u6587\u4ef6 &hellip; <a href=\"https:\/\/chen-hongyi.com\/?p=722\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-722","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=722"}],"version-history":[{"count":7,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/722\/revisions"}],"predecessor-version":[{"id":737,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/722\/revisions\/737"}],"wp:attachment":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}