{"id":4830,"date":"2020-02-27T10:39:44","date_gmt":"2020-02-27T02:39:44","guid":{"rendered":"https:\/\/www.xttblog.com\/?p=4830"},"modified":"2020-02-27T11:44:54","modified_gmt":"2020-02-27T03:44:54","slug":"user-must-be-authenticated-with-spring-security-before-authorization-can-be-completed","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4830","title":{"rendered":"User must be authenticated with Spring Security before authorization can be completed."},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u6700\u8fd1\u5728\u505a\u4e00\u4e2a OAuth2 \u5e73\u53f0\uff0c\u524d\u9762\u5b89\u6392\u4e86\u4e00\u4e2a\u9ad8\u7ea7\u5de5\u7a0b\u5e08\u5728\u505a\uff0c\u7ed3\u679c\u505a\u7684\u975e\u5e38\u4e0d\u7406\u60f3\u3002\u51fa\u73b0\u5404\u79cd\u95ee\u9898\u4e0d\u8bf4\uff0c\u8fd8\u9003\u8dd1\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u521a\u63a5\u624b\u8fd9\u4e2a\u4e71\u644a\u5b50\uff0c\u542f\u52a8\u9879\u76ee\uff0c\u521a\u60f3\u8bbf\u95ee\u4e00\u4e0b\uff0c\u5c31\u62a5\u4e86\u4e00\u4e2a\u9519\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">User must be authenticated with Spring Security before authorization can be completed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u8bf4\u4e00\u8bf4\u8fd9\u4e2a\u9519\u8bef\u5982\u4f55\u89e3\u51b3\uff01<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/gitee.com\/xmtblog\/img\/raw\/master\/oauth2-error.png\" alt=\"\" \/><figcaption>OAuth2 \u62a5\u9519<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u5728\u7f51\u4e0a\u4e5f\u67e5\u4e86\u4e0d\u5c11\u8d44\u6599\uff0c\u6bd4\u5982\u4e0a\u9762\u8fd9\u7bc7\u6587\u7ae0\u3002\u4f46\u662f\uff0c\u8bc4\u8bba\u533a\u5f88\u591a\u4eba\u7559\u8a00\u8bf4\u6ca1\u6cd5\u89e3\u51b3\u3002\u8fd9\u79cd\u7406\u89e3\u5176\u5b9e\u662f\u601d\u8def\u9519\u4e86\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ffd\u8e2a\u5f02\u5e38\u4fe1\u606f\u5f97\u77e5\uff0c\u662f AuthorizationEndpoint \u8fd9\u4e2a\u7c7b\u629b\u51fa\u7684\u5f02\u5e38\u3002\u901a\u8fc7\u8c03\u8bd5\u548c debug\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u4e4b\u6240\u4ee5\u629b\u51fa\u8fd9\u4e2a\u5f02\u5e38\u662f\u56e0\u4e3a\u4f60\u7684 oauth\/authorize \u8bf7\u6c42\u5e76\u6ca1\u6709\u88ab\u653e\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.authorizeRequests()\n.anyRequest()\n.authenticated()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u6539\u4e3a\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.authorizeRequests()\n.antMatchers(\"\/login\", \"\/oauth\/authorize\").permitAll()\n.anyRequest().authenticated();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u8d44\u6599<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/stackoverflow.com\/questions\/57618681\/user-must-be-authenticated-with-spring-security-before-authorization-can-be-comp\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">https:\/\/stackoverflow.com\/questions\/57618681\/user-must-be-authenticated-with-spring-security-before-authorization-can-be-comp<\/a><\/li><\/ul>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4830\">User must be authenticated with Spring Security before authorization can be completed.<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728\u505a\u4e00\u4e2a OAuth2 \u5e73\u53f0\uff0c\u524d\u9762\u5b89\u6392\u4e86\u4e00\u4e2a\u9ad8\u7ea7\u5de5\u7a0b\u5e08\u5728\u505a\uff0c\u7ed3\u679c\u505a\u7684\u975e\u5e38\u4e0d\u7406\u60f3\u3002\u51fa\u73b0\u5404\u79cd\u95ee\u9898\u4e0d\u8bf4\uff0c\u8fd8\u9003\u8dd1\u4e86 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[2084,1001,182,990,183],"class_list":["post-4830","post","type-post","status-publish","format-standard","hentry","category-java","tag-authorizationendpoint","tag-oauth2","tag-oauth","tag-sessionssecuritymanager","tag-spring-security"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4830"}],"version-history":[{"count":2,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4830\/revisions"}],"predecessor-version":[{"id":4832,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4830\/revisions\/4832"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}