设置身份验证和授权
在使用Kapacitor HTTP API时启用并要求基于用户的身份验证。Kapacitor可以将用户角色和权限存储在本地,或者使用InfluxDB Enterprise授权来验证请求。
如果您已经在使用InfluxDB Enterprise用户授权和认证服务来管理用户,我们建议对Kapacitor使用相同的服务。
设置内部 Kapacitor 授权
使用存储在Kapacitor中的基于用户的授权来验证对Kapacitor HTTP API的请求。
设置 InfluxDB Enterprise 授权
使用存储和管理在 InfluxDB Enterprise 中的基于用户的授权来验证对 Kapacitor HTTP API 的请求。
Kapacitor身份验证配置选项
以下与身份验证相关的配置选项可在
kapacitor.conf中找到,并且可以通过环境变量设置:
- [http]
- auth-enabled: 在Kapacitor HTTP API上启用并强制基本身份验证。
- [auth]
- enabled: 启用Kapacitor认证服务。
- cache-expiration: 消费者服务可以在其缓存中保持凭证文档的时间。
- bcrypt-cost: 使用bcrypt算法对密码进行哈希时使用的迭代次数。更高的值生成对暴力破解尝试更具抗性的哈希,但会导致略微更长的解析时间。
- * meta-addr: 连接到InfluxDB Enterprise元节点以访问用户和权限存储的地址。
- * meta-use-tls: 与InfluxDB Enterprise元节点通信时使用TLS。
- * meta-ca: InfluxDB Enterprise元节点的证书颁发机构文件的路径。
- * meta-cert: PEM编码证书文件的路径。
- * meta-key: PEM编码证书私钥的路径。
- * meta-insecure-skip-verify: 通过TLS连接时跳过链和主机验证。当使用自签名TLS证书时设置为
true。
kapacitor.conf中的示例认证设置
[http]
# ...
auth-enabled = true
# ...
[auth]
# Enable authentication for Kapacitor.
enabled = false
# User permissions cache expiration time.
cache-expiration = "10m"
# Cost to compute bcrypt password hashes.
# bcrypt rounds = 2^cost
bcrypt-cost = 10
# Address of an InfluxDB Enterprise meta server.
# If empty, InfluxDB Enterprise meta nodes are not used as a user store.
# host:port
meta-addr = "172.17.0.2:8091"
meta-use-tls = false
# Absolute path to PEM encoded Certificate Authority (CA) file.
# A CA can be provided without a key/certificate pair.
meta-ca = "/etc/kapacitor/ca.pem"
# Absolute paths to PEM encoded private key and server certificate files.
meta-cert = "/etc/kapacitor/cert.pem"
meta-key = "/etc/kapacitor/key.pem"
meta-insecure-skip-verify = false