{"id":7985,"date":"2019-04-17T11:12:22","date_gmt":"2019-04-17T03:12:22","guid":{"rendered":"https:\/\/aqzt.com\/7985.html"},"modified":"2019-04-17T11:12:22","modified_gmt":"2019-04-17T03:12:22","slug":"spring-security-5-2-0-m2-%e5%8f%91%e5%b8%83%ef%bc%8cspring-%e5%ae%89%e5%85%a8%e6%a1%86%e6%9e%b6","status":"publish","type":"post","link":"https:\/\/aqzt.com\/7985.html","title":{"rendered":"Spring Security 5.2.0.M2 \u53d1\u5e03\uff0cSpring \u5b89\u5168\u6846\u67b6"},"content":{"rendered":"<p><a href=\"https:\/\/www.oschina.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u6587\u7ae0\u8f6c\u8f7d\u5f00\u6e90\u4e2d\u56fd<\/a><\/p>\n<p>Spring Security 5.2.0.M2 \u5df2\u53d1\u5e03\uff0c\u8be5\u7248\u672c\u5305\u542b<a href=\"https:\/\/github.com\/spring-projects\/spring-security\/milestone\/132?closed=1\">\u8d85\u8fc7 100 \u5904\u66f4\u65b0<\/a>\u3002\u4e0b\u9762\u8bf4\u8bf4\u503c\u5f97\u5173\u6ce8\u7684\u66f4\u65b0\uff1a<\/p>\n<h2>OAuth 2.0<\/h2>\n<ul>\n<li>\u5ba2\u6237\u7aef\u652f\u6301 PKEC<\/li>\n<li>\n<p>OpenID \u8fde\u63a5&nbsp;RP-Initiated Logout<\/p>\n<\/li>\n<li>\n<p>\u80fd\u591f\u4f7f\u7528 JwtDecoder \u7684\u5bf9\u79f0\u5bc6\u94a5<\/p>\n<\/li>\n<li>\n<p>NimbusReactiveJwtDecoder \u80fd\u591f\u91c7\u7528\u81ea\u5b9a\u4e49\u5904\u7406\u5668<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u8d44\u6e90\u670d\u52a1\u5668\u4ee4\u724c\u81ea\u68c0<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u8d44\u6e90\u670d\u52a1\u5668\u591a\u79df\u6237\uff08\u4ec5\u9650 Servlet\uff09<\/p>\n<\/li>\n<\/ul>\n<h2>Core<\/h2>\n<ul>\n<li>\u5c06\u5bc6\u94a5\u6750\u6599\u8f6c\u6362\u4e3a\u5bc6\u94a5\u5b9e\u4f8b<\/li>\n<li>\u652f\u6301 JDK 12<\/li>\n<li>\u5f15\u5165 AuthenticationManagerResolver<\/li>\n<li>\u4e3a\u65b9\u6cd5\u53c2\u6570\u5f15\u5165 @CurrentSecurityContext<\/li>\n<\/ul>\n<p>\u4e0e\u4e4b\u524d\u7684 @AuthenticationPrincipal \u4e00\u6837\uff0c@CurrentSecurityContext \u4f7f\u7528\u53c2\u6570\u89e3\u6790\u5668\u6765\u68c0\u7d22 SecurityContext \u7684\u5404\u4e2a\u65b9\u9762\uff1a<\/p>\n<pre>\n\n<div class=\"codecolorer-container text solarized-dark\" style=\"overflow:auto;white-space:nowrap;width:800px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/><\/div><\/td><td><div class=\"text codecolorer\">public String hello(@CurrentSecurityContext<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; SecurityContext context) {<br \/>\n&nbsp; &nbsp; return Optional.ofNullable(context.getAuthentication())<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .map(Authentication::getName).orElse(&quot;world&quot;);<br \/>\n}<br \/>\n<br \/>\n\/\/ or<br \/>\n<br \/>\npublic String hello(@CurrentSecurityContext<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; (expression=&quot;authentication.name&quot;) String name) {<br \/>\n&nbsp; &nbsp; return Optional.ofNullable(name).orElse(&quot;world&quot;);<br \/>\n}<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n<\/pre>\n<h2>Web<\/h2>\n<ul>\n<li>\u652f\u6301 Clear-Site-Data \u6807\u5934<\/li>\n<li>\u652f\u6301 HSTS \u9884\u52a0\u8f7d<\/li>\n<li>\u5f15\u5165 CompositeHeaderWriter\uff0c\u4ee5\u53ca\u5176\u4ed6\u4e00\u4e9b&nbsp;<a href=\"https:\/\/github.com\/spring-projects\/spring-security\/issues\/6454\">header-writing cleanup<\/a><\/li>\n<\/ul>\n<p>\u8be6\u60c5\u53ef\u67e5\u770b<a href=\"https:\/\/spring.io\/blog\/2019\/04\/16\/spring-security-5-2-0-m2-released\">\u53d1\u5e03\u8bf4\u660e<\/a>\u3002<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<\/p>\n<p><a href=\"https:\/\/github.com\/spring-projects\/spring-security\/archive\/5.1.0.M2.zip\">Source code(zip)<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/spring-projects\/spring-security\/archive\/5.1.0.M2.tar.gz\">Source code(tar.gz)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u8f6c\u8f7d\u5f00\u6e90\u4e2d\u56fd Spring Security 5.2.0.M2 \u5df2\u53d1\u5e03\uff0c\u8be5\u7248\u672c\u5305\u542b\u8d85\u8fc7 100 \u5904\u66f4\u65b0\u3002\u4e0b\u9762\u8bf4\u8bf4\u503c\u5f97\u5173\u6ce8\u7684\u66f4\u65b0\uff1a OAuth 2.0 \u5ba2\u6237\u7aef\u652f\u6301 PKEC OpenID \u8fde\u63a5&nbsp;RP-Initiated Logout \u80fd\u591f\u4f7f\u7528 JwtDecoder \u7684\u5bf9\u79f0\u5bc6\u94a5 NimbusReactiveJwtDecoder \u80fd\u591f\u91c7\u7528\u81ea\u5b9a\u4e49\u5904\u7406\u5668 \u652f\u6301\u8d44\u6e90\u670d\u52a1\u5668\u4ee4\u724c\u81ea\u68c0 \u652f\u6301\u8d44\u6e90\u670d\u52a1\u5668\u591a\u79df\u6237\uff08\u4ec5\u9650 Servlet\uff09 Core \u5c06\u5bc6\u94a5\u6750\u6599\u8f6c\u6362\u4e3a\u5bc6\u94a5\u5b9e\u4f8b \u652f\u6301 JDK 12 \u5f15\u5165 Authenticatio<\/p>\n","protected":false},"author":1,"featured_media":6522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[2],"tags":[292,10],"collection":[],"_links":{"self":[{"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/posts\/7985"}],"collection":[{"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/comments?post=7985"}],"version-history":[{"count":0,"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/posts\/7985\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/media\/6522"}],"wp:attachment":[{"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/media?parent=7985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/categories?post=7985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/tags?post=7985"},{"taxonomy":"collection","embeddable":true,"href":"https:\/\/aqzt.com\/wp-json\/wp\/v2\/collection?post=7985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}