请问api验证应该如何设置,现在的api是公开的,谁都能调用,因为我的服务打算部署在公网。但是配置文件对这块配置内容没有具体说明。以下是默认配置,都不生效,api依然是无需验证的
[HTTP.Pushgw]
Enable = true
[HTTP.Pushgw.BasicAuth]
user001 = "ccc26da7b9aba533cbb263a36c07dcc5"
[HTTP.Alert]
Enable = true
[HTTP.Alert.BasicAuth]
user001 = "ccc26da7b9aba533cbb263a36c07dcc5"
[HTTP.Heartbeat]
Enable = true
[HTTP.Heartbeat.BasicAuth]
user001 = "ccc26da7b9aba533cbb263a36c07dcc5"
[HTTP.Service]
Enable = true
[HTTP.Service.BasicAuth]
user001 = "ccc26da7b9aba533cbb263a36c07dcc5"
测试结果:
curl -I http://1.2.3.4:17000/prometheus/v1/write
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 1301
Content-Type: text/html; charset=utf-8
Last-Modified: Thu, 20 Apr 2023 11:11:25 GMT
curl -I http://1.2.3.4:17000/v1/n9e/heartbeat
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 1301
Content-Type: text/html; charset=utf-8
Last-Modified: Thu, 20 Apr 2023 11:11:25 GMT
Date: Thu, 27 Apr 2023 03:44:11 GMT