elasticsearch中head插件中的定制增加用户名密码范例

时间:2022-02-15 15:19:48

在head插件目录下一般 在 elasticsearch目录下的 plugins\head目录 下 在 或 plugins\head\site目录下 有 一个index.html文件。把这个文件用下面代码替换:

<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<title>elasticsearch-head</title>
<link rel="stylesheet" href="_site/base/reset.css">
<link rel="stylesheet" href="_site/vendor.css">
<link rel="stylesheet" href="_site/app.css">
<script src="_site/i18n.js" data-baseDir="_site/lang" data-langs="en,fr,pt,zh,tr,ja"></script>
<script src="_site/vendor.js"></script>
<script src="_site/app.js"></script>
<script>
var loginClick = function() {
if(document.getElementById("userName").value!="admin" || document.getElementById("userPassword").value!="pwd654321"){
document.getElementById("isNotVerified").style.display="block";
return;
} else {
document.getElementById("loginDiv").style.display="none";
}
if(location.href.contains("/_plugin/")) {
var base_uri = location.href.replace(/_plugin\/.*/, '');
}
var args = location.search.substring(1).split("&").reduce(function(r, p) {
r[decodeURIComponent(p.split("=")[0])] = decodeURIComponent(p.split("=")[1]); return r;
}, {});
new app.App("body", {
id: "es",
base_uri: args["base_uri"] || base_uri,
auth_user : args["auth_user"] || "",
auth_password : args["auth_password"],
dashboard: args["dashboard"]
});
};
</script>
<link rel="icon" href="base/favicon.png" type="image/png">
</head>
<body>
<div width="100%" name="loginDiv" id="loginDiv" style="text-align: center;">
<div width="100%" style="text-align: center;">登录<br></div>
<div width="100%" style="text-align: center;">用户名:<input type="text" name="userName" id="userName"></div><br>
<div width="100%" style="text-align: center;">密 码:<input type="password" name="userPassword" id="userPassword"></div><br>
<div width="100%" style="text-align: center;"><button onclick="loginClick();">确定</button></div><br>
<div width="100%" id="isNotVerified" style="text-align: center;display: none"><font color="red">用户名或密码输入不正确</font></div><br>
</div>
</body>
</html>

  

---------------------
作者:whohu
来源:CSDN
原文:https://blog.csdn.net/whohu/article/details/80189619
版权声明:本文为博主原创文章,转载请附上博文链接!