本地配置 #
通过安全模块的本地 YAML 配置文件可以方便的管理默认的内置用户或
隐藏的保留资源,例如 admin
管理员用户。不过通过 INFINI Console 或者 REST API 来创建其他用户、角色、映射、操作组和租户可能更容易。
user.yml #
此文件包含您要添加到内部用户数据库的默认初始用户。
配置文件里面的密码不能是明文,必须使用 Hash 之后的密码,通过命令 ./bin/hash_password.sh -p <new-password>
可以生成一个密码哈希。
_meta:
type: "user"
config_version: 2
admin:
hash: "$2y$12$ZXx5R8NfuW2TYPOdGNY7a.43WKKBMCtN9aJywYWjAz9i11w7SrkqG"
reserved: true
external_roles:
- "admin"
description: "Default admin user"
readonly:
hash: "$2y$12$d9I16.5qpYhhsbiGN4zqdeA4k6BeMl/yEKRvTo3gzxFp8UC57EgJ."
reserved: false
external_roles:
- "readall"
description: "Default readonly user"
role.yml #
此文件包含要添加到内置数据库的默认初始角色。除了一些元数据之外,这个文件默认是是空的,因为系统已经了内置了若干角色,可以根据需要进行角色扩展。
complex-role:
reserved: false
hidden: false
cluster:
- "read"
- "cluster:monitor/nodes/stats"
- "cluster:monitor/task/get"
indices:
- names:
- "kibana_sample_data_*"
query: '{"match": {"FlightDelay": true}}'
field_security:
- "~FlightNum"
field_mask:
- "Carrier"
privileges:
- "read"
static: false
_meta:
type: "roles"
config_version: 2
role_mapping.yml #
此文件主要设置用户角色的映射关系。
manage_snapshots:
reserved: true
hidden: false
external_roles:
- "snapshotrestore"
hosts: []
users: []
privilege.yml #
此文件包含您要添加到安全模块的默认权限集合。
除了一些元数据之外,该文件默认为空,因为安全模块已经内置不少了权限集合。这些集合基本上涵盖了常用的场景,这里的配置根据需要自行扩展。
my-action-group:
reserved: false
hidden: false
privileges:
- "indices:data/write/index*"
- "indices:data/write/update*"
- "indices:admin/mapping/put"
- "indices:data/write/bulk*"
- "read"
- "write"
static: false
_meta:
type: "privilege"
config_version: 2
nodes_dn.yml #
_meta:
type: "nodesdn"
config_version: 2
# Define nodesdn mapping name and corresponding values
# cluster1:
# nodes_dn:
# - CN=*.example.com
注意 #
任何对权限配置文件的修改: 如 user.yml,role.yml,role_mapping.yml 修改后必须以管理员身份删除.security 索引,然后重启服务,才能生效。 删除命令: curl -XDELETE -k –cert admin.crt –key admin.key ‘https://localhost:9200/.security’