{"id":130,"date":"2023-07-20T16:38:58","date_gmt":"2023-07-20T07:38:58","guid":{"rendered":"https:\/\/knowledge.comadori.com\/wp\/?p=130"},"modified":"2023-07-25T14:23:52","modified_gmt":"2023-07-25T05:23:52","slug":"create-htpasswd-file-for-basic-authentication","status":"publish","type":"post","link":"https:\/\/knowledge.comadori.com\/wp\/?p=130","title":{"rendered":"create .htpasswd file for basic authentication"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">GOAL<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Basic \u8a8d\u8a3c\u3067\u4f7f\u7528\u3059\u308b .htpasswd \u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create .htpasswd file for use with Basic authentication<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ENVIRONMENT<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>apache2.4<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">PARAMETER<\/h2>\n\n\n\n<dl>\n<dt>create option<\/dt>\n<dd>\nPARAM_01: <br>\n<label><input type=\"radio\" name=\"PARAM_01\" value=\"-bc\" checked=\"checked\"> create new file<\/label><br>\n<label><input type=\"radio\" name=\"PARAM_01\" value=\"-b\"> append\/update existt file<\/label><br>\n<\/dd>\n<\/dl>\n\n\n\n<dl>\n<dt>.htpasswd file full path<\/dt>\n<dd>PARAM_02: <input type=\"text\" name=\"PARAM_02\"><\/dd>\n<\/dl>\n\n\n\n<dl>\n<dt>user account<\/dt>\n<dd>PARAM_03: <input type=\"text\" name=\"PARAM_03\"><\/dd>\n<\/dl>\n\n\n\n<dl>\n<dt>user password<\/dt>\n<dd>PARAM_04: <input type=\"text\" name=\"PARAM_04\"><\/dd>\n<\/dl>\n\n\n\n<h2 class=\"wp-block-heading\">CODE<\/h2>\n\n\n\n<script>\nconst param_reflector = (e) => {\n  let original_codes = [];\n  const reflection = () => {\n    original_codes.forEach((code) => {\n      let content = code.content;\n      document.querySelectorAll('[name^=\"PARAM_\"]').forEach((param, idx) => {\n        switch(param.type) {\n          case 'radio':\n            if (!param.checked) return;\n            break;\n          default:\n            if (!param.value) return;\n          }\n          content = content.replaceAll(`[${param.name}]`, param.value);\n          content = content.replaceAll(`<span class=\"token punctuation\">[<\/span>${param.name}<span class=\"token punctuation\">]<\/span>`, param.value);\n      });\nconsole.log(content)\n      code.elem.innerHTML = content;\n    });\n  };\n  setTimeout(() => {\n    document.querySelectorAll('.code code').forEach((elem, idx) => {\n      original_codes.push({elem: elem, content: elem.innerHTML});\n    }, 500);\n  });\n  document.querySelectorAll('[name^=\"PARAM_\"]').forEach((elem, idx) => {\n    elem.addEventListener('change', reflection);\n  });\n};\ndocument.addEventListener('DOMContentLoaded', param_reflector);\n<\/script>\n\n\n\n<h3 class=\"wp-block-heading\">Enter password inline<\/h3>\n\n\n\n<div class=\"hcb_wrap code\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>htpasswd [PARAM_01] [PARAM_02]\/.htpasswd [PARAM_03] [PARAM_04]<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading code\">Enter password interactively<\/h3>\n\n\n\n<div class=\"hcb_wrap code\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>htpasswd [PARAM_01] [PARAM_02]\/.htpasswd [PARAM_03]<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">NOTICE<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u30a4\u30f3\u30e9\u30a4\u30f3\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6253\u3061\u8fbc\u3080\u969b\u306f\u3001\u30b7\u30a7\u30eb\u306e\u5c65\u6b74\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u8a18\u9332\u3055\u308c\u308b\u70b9\u306b\u6ce8\u610f\u3059\u308b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When typing passwords inline, note that the password is recorded in the shell history.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basic \u8a8d\u8a3c\u3067\u4f7f\u7528\u3059\u308b .htpasswd \u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210 Create .htpasswd file for use with Basic authentication create option PARAM_01 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6],"tags":[8],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-2-4","category-apache","tag-htaccess"],"_links":{"self":[{"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":12,"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":173,"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions\/173"}],"wp:attachment":[{"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/knowledge.comadori.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}