solr的客户端:
php:
composer require solarium/solarium
直接API调用:
设置了用户名和密码的,在header头下添加认证:
Authorization: Basic base64(username:password) // base64(username:password) 需要手动生成
然后就可以调用API了.
php下生成加密信息:
//官方加密方式少了一个 ')' 号
base64(sha256(sha256(salt+password))) base64(salt), 中间有个空格
//security.json配置如下:
{
"authentication":{
"blockUnknown": true,
"class":"solr.BasicAuthPlugin",
"credentials":{"solr":"ua1+S+w/1HipuKpWrOrhGkhH6mLJe+j0YvzPLOoe0KM= aGFoYQ=="}, // 分别是用户名和 加密的密码以及密码盐
"realm":"My Solr users",
"forwardCredentials": false
}
}
//加密算法
$name= 'solr';
$pwd = 'hello solr';
$salt = 'haha';
$hash = hash('sha256', hash('sha256', $salt.$pwd, true), true); // true 表示输出原始二进制数据,必须要设置,否则生成的hash值验证不通过
$res_pwd = base64_encode($hash);
$res_salt = base64_encode($salt);
dd($res_pwd.'-----'.$res_salt);
base64在线工具: https://base64.us/
