zxz*_*zxz 33 authorization neo4j
我使用的版本是neo4j-enterprise-2.2.0-M02
我的问题是:如何在后端或浏览器中配置用户(如添加新用户,更改密码等)而不是REST API?我可以通过neo4j-shell来做吗?想象一下我是一名DBA,通过REST API做这件事并不是很方便.
任何帮助将不胜感激!
sub*_*ris 51
您可以使用浏览器而不是API.只需转到http://localhost:7474(或Web控制台绑定的任何IP),系统将提示您更改密码.经过身份验证后,使用该命令:server change-password再次更改密码.
目前尚无法在系统中创建多个用户帐户.
您可以使用该命令:help server查看可用的身份验证命令.
Bre*_*ata 43
虽然仍在使用REST API,但我会将cURL选项抛给那些无法访问Web浏览器的人(例如AWS实例):
$ curl -H "Content-Type: application/json" -X POST -d '{"password":"WHATEVER THE PASSWORD IS"}' -u neo4j:neo4j http://localhost:7474/user/neo4j/password
Run Code Online (Sandbox Code Playgroud)
另一种选择是直接修改auth文件并重新启动neo.这样做,您甚至可以更改用户名!
跑
find/-name dbms
对我来说,这给了一个打击:
的/ var/lib中/ Neo4j的/数据/ DBMS/AUTH
将此代码保存为build_auth_string.sh:
#!/bin/bash
DEFAULT_IFS="$IFS"
SALT_LEN=32
# either read from stdin or use the argument
if [ -z "$1" ]; then
read INPUT
else
INPUT="$1"
fi
if [ -z "$INPUT" ]; then
echo "correct format <uname:pass>"
exit
fi
IFS=':'
read -a UNAME_PASS <<< "$INPUT"
UNAME="${UNAME_PASS[0]}"
PASS="${UNAME_PASS[1]}"
# representing the password in hex format like \xAB\x0C etc
# HEX_PASS=$(echo -n $PASS | xxd -p | awk '{print toupper($1);}' | sed -r 's/(.{2})/\\x\1/g')
HEX_PASS=$(echo -n $PASS | hexdump -v -e '"\\\x" 1/1 "%02X"')
# echo $HEX_PASS
# create the salt and store it in hex format
SALT=$(cat /dev/urandom | tr -dc 'a-f0-9' | fold -w $SALT_LEN | head -n 1)
# SALT="28FD26AD92D6D2D8820E969F3F3732B4"
HEX_SALT=$(echo -n $SALT | sed -r 's/(.{2})/\\x\1/g')
# calculate the sha256 sum of the salt and password value
# need to split the output because the output ends with a hyphen
IFS=' '
read -a PASSWORD_HASH_ARRAY <<< $(printf $HEX_SALT$HEX_PASS | sha256sum)
PASSWORD_HASH="${PASSWORD_HASH_ARRAY[0]}"
# echo "$UNAME;$PASS;$SALT"
# echo "$PASSWORD_HASH"
# and print out the auth string
COMBINED=$(echo -n "$PASSWORD_HASH,$SALT" | awk '{print toupper($1);}')
echo "$UNAME:SHA-256,$COMBINED:"
IFS="$DEFAULT_IFS"
Run Code Online (Sandbox Code Playgroud)
上面的代码来自https://github.com/artsince/docker-neo4j-auth/blob/master/build_auth_string.sh - 我在这里张贴它只是包装..
然后运行上面的脚本就好了
build_auth_string.sh myUsername:myP @ ssw0rd
将其复制/粘贴到您的auth文件中,替换之前的任何内容,然后重新启动neo4j :)
全新安装的Neo4j 2.2.x有一个用户'neo4j',初始密码为'neo4j'.在您可以执行任何操作之前,您需要更改密码.
通过调用httpie与REST API进行交互,可以从命令行轻松完成此操作.例如,要设置新密码"foobar",请运行以下命令:
http -a neo4j:neo4j POST http://localhost:7474/user/neo4j/password password=foobar
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34663 次 |
| 最近记录: |