{"id":133,"date":"2020-03-03T13:12:33","date_gmt":"2020-03-03T04:12:33","guid":{"rendered":"https:\/\/buru.wew.jp\/?p=133"},"modified":"2025-08-31T22:52:02","modified_gmt":"2025-08-31T13:52:02","slug":"terasoluna5%e3%81%a7springsecurity%e3%82%92%e4%bd%bf%e3%81%86%e3%81%ab%e3%81%82%e3%81%9f%e3%81%a3%e3%81%a6%e3%81%ae%e3%83%a1%e3%83%a2","status":"publish","type":"post","link":"https:\/\/buru.wew.jp\/?p=133","title":{"rendered":"TERASOLUNA5\u3067SpringSecurity\u3092\u4f7f\u3046\u306b\u3042\u305f\u3063\u3066\u306e\u30e1\u30e2"},"content":{"rendered":"\n<p>SpringSecurityFilterChain\u304c\u539f\u56e0\u3067CSRF\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u305f\u6642\u306b\u8abf\u3079\u305f\u30e1\u30e2\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u7c21\u5358\u306b??\u8aac\u660e\u3059\u308b\u3068\u3001<\/p>\n\n\n\n<p>JSP\u3067&lt;form:form&gt;\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u305f\u5834\u5408\u3001SpringSecurity\u306b\u5fc5\u8981\u306a\u30c8\u30fc\u30af\u30f3\u3092\u30bb\u30c3\u30c8\u3057\u3066\u9001\u4fe1\u3057\u3066\u3044\u3066\u3001\u305d\u306e\u30c8\u30fc\u30af\u30f3\u3092\u9001\u3089\u306a\u3044\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\u3068Filter\u30af\u30e9\u30b9\u3067\u30c8\u30fc\u30af\u30f3\u304c\u306a\u3044\u305f\u3081CSRF\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<p><strong>&nbsp;hidden\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8907\u6570\u8ffd\u52a0\u6a5f\u80fd<\/strong><\/p>\n\n\n\n<p><strong>org.terasoluna.gfw.web.mvc.support.CompositeRequestDataValueProcessor &nbsp;<\/strong><\/p>\n\n\n\n<p>requestDataValueProcessor\u306b\u306f\u672c\u6765\u30af\u30e9\u30b9\u3092\u4e00\u3064\u3057\u304b\u6307\u5b9a\u3067\u304d\u306a\u3044\u304c\u3001TERASOLUNA\u304c\u63d0\u4f9b\u3059\u308bCompositeRequestDataValueProcessor\u30af\u30e9\u30b9\u306b\u3088\u308a\u30ea\u30b9\u30c8\u5f62\u5f0f\u3067\u8907\u6570hidden\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u30af\u30e9\u30b9\u3092\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p>\u958b\u767a\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3<a href=\"http:\/\/terasolunaorg.github.io\/guideline\/5.5.1.RELEASE\/ja\/ArchitectureInDetail\/WebApplicationDetail\/DoubleSubmitProtection.html#setting\">http:\/\/terasolunaorg.github.io\/guideline\/5.5.1.RELEASE\/ja\/ArchitectureInDetail\/WebApplicationDetail\/DoubleSubmitProtection.html#setting<\/a><\/p>\n\n\n\n<p><strong>CSRF\u30c1\u30a7\u30c3\u30af<\/strong><\/p>\n\n\n\n<p><strong>org.springframework.security.web.reactive.result.view.CsrfRequestDataValueProcessor&nbsp;<\/strong><\/p>\n\n\n\n<p>hidden\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u8ffd\u52a0\u3057\u305f\u9805\u76ee\u3092\u4ee5\u4e0b\u30af\u30e9\u30b9\u306egetExtraHiddenFields\u306b\u3088\u308a\u53d6\u5f97\u3057\u3001\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\u3002&nbsp;<\/p>\n\n\n\n<p><strong>\u4e8c\u91cd\u9001\u4fe1\u30c1\u30a7\u30c3\u30af<\/strong><\/p>\n\n\n\n<p><strong>org.terasoluna.gfw.web.token.transaction.TransactionTokenRequestDataValueProcessor<\/strong><\/p>\n\n\n\n<p>\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u30c8\u30fc\u30af\u30f3\u3092\u3001Spring MVC\u30bf\u30b0\u306e&lt;form:form&gt;\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066Hidden\u9818\u57df\u306b\u81ea\u52d5\u7684\u306b\u57cb\u3081\u8fbc\u3080\u305f\u3081\u306e\u30af\u30e9\u30b9&nbsp;<\/p>\n\n\n\n<p><strong>org.springframework.web.servlet.tags.form.FormTag<\/strong><\/p>\n\n\n\n<p>Spring\u306e\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u306e\u5b9f\u88c5\u3092\u3057\u3066\u3044\u308b\u3002<br>&lt;form:form&gt;\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30d5\u30a9\u30fc\u30e0\u3092\u9001\u4fe1\u3059\u308b\u3068\u3001\u5f53\u8a72\u30af\u30e9\u30b9\u3068RequestDataValueProcessor\u304c\u9023\u643a\u3057\u3066hidden\u9805\u76ee\u3092JSP\u306b\u5b9a\u7fa9\u305b\u305a\u306b\u5b9f\u73fe\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<p><strong>FormTag#writeTagContent<\/strong><\/p>\n\n\n\n<p>\u30bf\u30b0\u306e\u5c5e\u6027\u3092\u8ffd\u52a0(\u66f8\u304d\u51fa\u3057)\u3059\u308b\u3002<\/p>\n\n\n\n<p><strong>FormTag#writeHiddenFields<\/strong><\/p>\n\n\n\n<p>RequestDataValueProcessor\u306b\u5b9a\u7fa9\u3057\u305fhidden\u9805\u76ee(CSRF\u30c1\u30a7\u30c3\u30af\u3084\u4e8c\u91cd\u9001\u4fe1\u30c1\u30a7\u30c3\u30af)\u3092\u30bf\u30b0\u5185\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3059\u308b<\/p>\n\n\n\n<p>&nbsp;RESTAPI\u3067SpringSecurity\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u306b\u5f15\u3063\u304b\u304b\u308b\u5834\u5408\u306f\u30bf\u30b0\u5185\u306e\u3067\u751f\u6210\u3057\u305f\u30c8\u30fc\u30af\u30f3\u60c5\u5831\u3092JSP\u5185\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u30d8\u30c3\u30c0\u306b\u8ffd\u52a0\u3057\u3066\u9001\u4fe1\u3059\u308c\u3070CSRF\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3067\u304d\u308b\u3002&nbsp;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">xmlhttp.setRequestHeader(\u201cX-CSRF-TOKEN\u201d, form1._csrf.value);<\/pre>\n\n\n\n<p>\"form1\"\u306f&lt;form:form&gt;\u30bf\u30b0\u306ename\u5c5e\u6027\u5024<br>\u203b\u95a2\u4fc2\u3059\u308b\u30af\u30e9\u30b9<br><strong>org.springframework.security.web.csrf.CsrfFilter<\/strong><\/p>\n\n\n\n<p>SpringSecurityFilterChain\u306b\u3064\u3044\u3066\u306f\u3053\u3061\u3089<br><a href=\"https:\/\/qiita.com\/opengl-8080\/items\/c105152c9ca48509bd0c\">https:\/\/qiita.com\/opengl-8080\/items\/c105152c9ca48509bd0c<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SpringSecurityFilterChain\u304c\u539f\u56e0\u3067CSRF\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u305f\u6642\u306b\u8abf\u3079\u305f\u30e1\u30e2\u3067\u3059\u3002 \u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u7c21\u5358\u306b??\u8aac\u660e\u3059\u308b\u3068\u3001 JSP\u3067&lt;form:form&gt;\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u305f\u5834\u5408\u3001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":259,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"jetpack_featured_media_url":"https:\/\/buru.wew.jp\/wp-content\/uploads\/2022\/06\/buru-1-scaled.jpg","_links":{"self":[{"href":"https:\/\/buru.wew.jp\/index.php?rest_route=\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buru.wew.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buru.wew.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buru.wew.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buru.wew.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=133"}],"version-history":[{"count":2,"href":"https:\/\/buru.wew.jp\/index.php?rest_route=\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/buru.wew.jp\/index.php?rest_route=\/wp\/v2\/posts\/133\/revisions\/209"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buru.wew.jp\/index.php?rest_route=\/wp\/v2\/media\/259"}],"wp:attachment":[{"href":"https:\/\/buru.wew.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buru.wew.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buru.wew.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}