{"id":83958,"date":"2020-05-12T12:57:31","date_gmt":"2020-05-12T04:57:31","guid":{"rendered":"http:\/\/4563.org\/?p=83958"},"modified":"2020-05-12T12:57:31","modified_gmt":"2020-05-12T04:57:31","slug":"spring-security-%e7%ae%a1%e7%90%86%e7%b3%bb%e7%bb%9f-admin-login-%e5%92%8c%e5%89%8d%e7%ab%af%e4%b8%8e%e6%99%ae%e9%80%9a%e7%94%a8%e6%88%b7%e4%ba%a4%e4%ba%92%e7%9a%84-user-login-%e5%b8%8c%e6%9c%9b","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=83958","title":{"rendered":"Spring Security \u7ba1\u7406\u7cfb\u7edf\/admin\/login \u548c\u524d\u7aef\u4e0e\u666e\u901a\u7528\u6237\u4ea4\u4e92\u7684\/user\/login \u5e0c\u671b\u7528\u4e24\u4e2a\u4e0d\u540c\u7684 UserDetailsService\uff0c\u8be5\u548b\u6574\u554a\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Spring Security \u7ba1\u7406\u7cfb\u7edf\/admin\/login \u548c\u524d\u7aef\u4e0e\u666e\u901a\u7528\u6237\u4ea4\u4e92\u7684\/user\/login \u5e0c\u671b\u7528\u4e24\u4e2a\u4e0d\u540c\u7684 UserDetailsService\uff0c\u8be5\u548b\u6574\u554a\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u8c22\u8c22      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1538550\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nvkou <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u662f\u4e2a\u63a5\u53e3\u3002\u6709\u5f88\u591a\u5b9e\u73b0\uff0c\u4efb\u4f55\u5e26\u6743\u9650\u7684\u5b9e\u73b0\u90fd\u80fd\u6ee1\u8db3\u3002\u6211\u4eec\u7528\u7684\u662f keycloak                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1538551\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sunqian <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528\u81ea\u5b9a\u4e49\u7684 filter \u53ef\u4ee5\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1538552\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @nvkou \u989d\u3002\u3002\u8c22\u8c22 \u6211\u5176\u5b9e\u60f3\u95ee\u4e0b \u5c31\u662f\u9488\u5bf9\u4e0d\u540c\u60c5\u666f\u9002\u7528\u4e0d\u540c UserService \u7684\u5b9e\u73b0\uff0c\u8be5\u600e\u4e48\u628a\u8fd9\u4e2a\u914d\u7f6e\u544a\u77e5\u6211\u7684\u9879\u76ee\u3002\u3002\u5c31<\/p>\n<p>@Configuration<br \/>class SpringSecurityConfig extends WebSecurityConfigurerAdapter<\/p>\n<p>\u91cc\u9762\u7684 configure \u65b9\u6cd5\u8be5\u5982\u4f55\u914d\u7f6e\u3002\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1538553\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ourslay <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81ea\u5b9a\u4e49 Filter \u7ee7\u627f UsernamePasswordAuthenticationFilter\uff0c\u5206\u522b\u5b9e\u73b0\u5bf9 user\/admin \u7684 AuthenticationManager<\/p>\n<p>configure \u914d\u7f6e<br \/>&#8220;`<br \/> .addFilter(new MultipleAuthenticationFilter(adminAuthenticationManager(), &#8220;\/admin\/login&#8221;))<br \/> .addFilter(new MultipleAuthenticationFilter(userAuthenticationManager(), &#8220;\/user\/login&#8221;));<\/p>\n<p>&#8220;`<br \/>AuthenticationManager \u914d\u7f6e<br \/>&#8220;`<br \/>List&lt;AuthenticationProvider&gt; providers = new ArrayList&lt;&gt;();<br \/> DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();<br \/> daoAuthenticationProvider.setUserDetailsService(adminDetailsService()); \/\/ or userDetailsService<br \/> providers.add(daoAuthenticationProvider);<br \/> return new ProviderManager(providers);<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1538554\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ourslay \u591a\u8c22\u8001\u54e5\uff0c\u80fd\u8bf4\u4e00\u4e0b\u600e\u4e48\u5b66\u7684\u4e48\uff1f\u6211\u8bd5\u8fc7\u5543 spring security \u5b98\u65b9\u6587\u6863\uff0c\u5543\u5f97\u8111\u74dc\u75bc\u4f46\u6ca1\u8bb0\u4f4f\u591a\u5c11\u4e1c\u897f\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1538555\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ourslay <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/docs.spring.io\/spring-security\/site\/docs\/5.4.0-M1\/reference\/html5\/#servlet-architecture<br \/>\u6587\u6863\u5199\u4e0d\u9519\u3002\u591a\u770b\u770b\u51e0\u904d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1538556\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fangyuanyoudu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u770b\u770b\u6155\u8bfe\u7f51 jojo \u8001\u5e08\u7684\u8001\u89c6\u9891\uff0c\u770b\u5b8c\u8001\u89c6\u9891\u518d\u770b cloud \u89c6\u9891\uff0c\u5728\u56de\u8fc7\u5934\u770b\u8001\u89c6\u9891\u3002\u4f1a\u5f88\u6709\u610f\u601d\u7684\uff0c\u795d\u597d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1538557\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fangyuanyoudu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u91cc\u9762\u80af\u5b9a\u6709\u4f60\u95ee\u9898\u7684\u7b54\u6848\uff0c\u4e0d\u4ec5\u9650\u4e8e\u6b64                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Spring Security \u7ba1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/83958"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=83958"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/83958\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83958"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}