Hi.
According to https://grafana.com/docs/http_api/auth/ Grafana’s HTTP API will accept Basic Authentication using the same user / password as can be used to log in to the standard web interface.
The example is given using curl, and this works:
curl “http://admin:admin@localhost:3000/api/org”
{“id”:1,“name”:“Main Org.”,“address”:{“address1”:"",“address2”:"",“city”:"",“zipCode”:"",“state”:"",“country”:""}}
However, the same request made using wget fails:
wget -O- “http://admin:admin@localhost:3000/api/org”
–2019-05-10 11:14:36-- http://admin:password@localhost:3000/api/org
Resolving localhost (localhost)… 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:3000… connected.
HTTP request sent, awaiting response… 401 Unauthorized
Unknown authentication scheme.
Username/Password Authentication Failed.
This turns out to be because curl sends the username / password immediately in the first HTTP request, whereas wget works more like a standard browser, which makes the request without authentication, expects a 401 HTTP response, and then sends the request again, this time including the authentication credentials.
However, Grafana sends the 401 HTTP response without a WWW-Authenticate header, so wget doesn’t reply with an authenticated request.
This header is a required header in a 401 response according to https://tools.ietf.org/html/rfc1945#section-10.16 and https://tools.ietf.org/html/rfc7235#section-4
Can this header be added to a future version of Grafana so that standard clients can authenticate to the HTTP API?
Thanks,
Antony.