diff options
-rwxr-xr-x | tests/health_mgmtapi/health-cmdapi-test.sh.in | 2 | ||||
-rw-r--r-- | web/api/health/README.md | 10 | ||||
-rw-r--r-- | web/server/web_client.c | 13 |
3 files changed, 9 insertions, 16 deletions
diff --git a/tests/health_mgmtapi/health-cmdapi-test.sh.in b/tests/health_mgmtapi/health-cmdapi-test.sh.in index 0847be0079..5e218b11e4 100755 --- a/tests/health_mgmtapi/health-cmdapi-test.sh.in +++ b/tests/health_mgmtapi/health-cmdapi-test.sh.in @@ -41,7 +41,7 @@ check () { cmd () { echo -e "${WHITE}Cmd '${1}', expecting '${2}'" - RESPONSE=$(curl -s "http://$URL/api/v1/manage/health?${1}" -H "Authorization: Bearer $TOKEN" 2>&1) + RESPONSE=$(curl -s "http://$URL/api/v1/manage/health?${1}" -H "X-Auth-Token: $TOKEN" 2>&1) if [ "${RESPONSE}" != "${2}" ] ; then echo -e "${RED}ERROR: Response '${RESPONSE}' != '${2}'" err=$((err+1)) diff --git a/web/api/health/README.md b/web/api/health/README.md index cbc8aaac4b..2003a61e04 100644 --- a/web/api/health/README.md +++ b/web/api/health/README.md @@ -61,7 +61,7 @@ The API is available by default, but it is protected by an `api authorization to You can access the API via GET requests, by adding the bearer token to an `Authorization` http header, like this: ``` -curl "http://myserver/api/v1/manage/health?cmd=RESET" -H "Authorization: Bearer Mytoken" +curl "http://myserver/api/v1/manage/health?cmd=RESET" -H "X-Auth-Token: Mytoken" ``` The command `RESET` just returns netdata to the default operation, with all health checks and notifications enabled. @@ -71,13 +71,13 @@ If you've configured and entered your token correclty, you should see the plain If all you need is temporarily disable all health checks, then you issue the following before your maintenance period starts: ``` -curl "http://myserver/api/v1/manage/health?cmd=DISABLE ALL" -H "Authorization: Bearer Mytoken" +curl "http://myserver/api/v1/manage/health?cmd=DISABLE ALL" -H "X-Auth-Token: Mytoken" ``` The effect of disabling health checks is that the alarm criteria are not evaluated at all and nothing is written in the alarm log. If you want the health checks to be running but to not receive any notifications during your maintenance period, you can instead use this: ``` -curl "http://myserver/api/v1/manage/health?cmd=SILENCE ALL" -H "Authorization: Bearer Mytoken" +curl "http://myserver/api/v1/manage/health?cmd=SILENCE ALL" -H "X-Auth-Token: Mytoken" ``` Alarms may then still be raised and logged in netdata, so you'll be able to see them via the UI. @@ -85,7 +85,7 @@ Alarms may then still be raised and logged in netdata, so you'll be able to see Regardless of the option you choose, at the end of your maintenance period you revert to the normal state via the RESET command. ``` - curl "http://myserver/api/v1/manage/health?cmd=RESET" -H "Authorization: Bearer Mytoken" + curl "http://myserver/api/v1/manage/health?cmd=RESET" -H "X-Auth-Token: Mytoken" ``` ### Disable or silence specific alarms @@ -108,7 +108,7 @@ To clear all selectors and reset the mode to default, use the `RESET` command. The following example silences notifications for all the alarms with context=load: ``` -curl "http://myserver/api/v1/manage/health?cmd=SILENCE&context=load" -H "Authorization: Bearer Mytoken" +curl "http://myserver/api/v1/manage/health?cmd=SILENCE&context=load" -H "X-Auth-Token: Mytoken" ``` #### Selection criteria diff --git a/web/server/web_client.c b/web/server/web_client.c index 5ae764b1d5..4e34ae3a33 100644 --- a/web/server/web_client.c +++ b/web/server/web_client.c @@ -732,7 +732,7 @@ static inline char *http_header_parse(struct web_client *w, char *s, int parse_u hash_accept_encoding = simple_uhash("Accept-Encoding"); hash_donottrack = simple_uhash("DNT"); hash_useragent = simple_uhash("User-Agent"); - hash_authorization = simple_uhash("Authorization"); + hash_authorization = simple_uhash("X-Auth-Token"); } char *e = s; @@ -777,15 +777,8 @@ static inline char *http_header_parse(struct web_client *w, char *s, int parse_u } else if(parse_useragent && hash == hash_useragent && !strcasecmp(s, "User-Agent")) { w->user_agent = strdupz(v); - } else if(hash == hash_authorization&& !strcasecmp(s, "Authorization")) { - if (strlen(v) > 8) { // Must contain at least "Bearer " - char *auth_key=v+6; - *auth_key='\0'; - if (!strcasecmp(v,"Bearer")) { - auth_key++; - w->auth_bearer_token=strdupz(auth_key); - } - } + } else if(hash == hash_authorization&& !strcasecmp(s, "X-Auth-Token")) { + w->auth_bearer_token = strdupz(v); } #ifdef NETDATA_WITH_ZLIB else if(hash == hash_accept_encoding && !strcasecmp(s, "Accept-Encoding")) { |