solr-web界面增加登录认证
Posted 菠萝小妹
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了solr-web界面增加登录认证相关的知识,希望对你有一定的参考价值。
目录
配置tomcat-user.xml
找到 tomcat 下 conf 文件下增加 tomcat-user.xml
<?xml version=\'1.0\' encoding=\'utf-8\'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <tomcat-users> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. --> <!-- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ..> that surrounds them. <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> --> <user username="admin" password="wodemima" roles="admin,manager"/> </tomcat-users>
username 你的用户名
password 你的密码
roles 你的用户界别
配置web.xml
配置 solr 下 WEB-INFO 下的web.xml,在最后增加下面代码
<security-constraint> <web-resource-collection> <web-resource-name>Restrict access to Solr admin</web-resource-name> <url-pattern>/admin/*</url-pattern> <http-method>DELETE</http-method> <http-method>GET</http-method> <http-method>POST</http-method> <http-method>PUT</http-method> </web-resource-collection> <auth-constraint> <role-name>manager</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>default</realm-name> </login-config>
界面展示
之后重启tomcat,访问界面,就会出现一下界面:
输入你自己设定的用户和密码即可进行登录。
除了这种方法还可以增加negix方向代理。个人觉得negix反向代理更安全。
以上是关于solr-web界面增加登录认证的主要内容,如果未能解决你的问题,请参考以下文章
Express实战 - 应用案例- realworld-API - 路由设计 - mongoose - 数据验证 - 密码加密 - 登录接口 - 身份认证 - token - 增删改查API(代码片段