kapacitor icon indicating copy to clipboard operation
kapacitor copied to clipboard

[alerta] token header prefix

Open allen13 opened this issue 9 years ago • 12 comments

Back in December I merged a pull request that changed the alerta Authorization prefix from Bearer to Key because of an issue experienced by @emirozer https://github.com/influxdata/kapacitor/issues/1076.

I was running a custom version of alerta at the time so I assumed that I had changed Bearer to Key myself. On further inspection I realized that alerta officialy started using the Bearer prefix a year ago. https://github.com/guardian/alerta/commit/46e52094013f0c19a664f3aeb7ebdf1bfcbf64f4 which means @emirozer was using an older version of alerta.

I have been running a custom version of kapacitor for myself that uses Bearer so I haven't had any issues, but going forward there is a chance that someone will run into this again. I am proposing that the prefix be configurable. The default value would be Bearer.

I will work on a pull request in the coming days that addresses this. I will be sure to alert @emirozer if the pull request gets accepted.

allen13 avatar Feb 02 '17 22:02 allen13

@allen13 Thanks for being proactive on this. I'll keep an eye out for the PR.

nathanielc avatar Feb 02 '17 22:02 nathanielc

@emirozer Once this commit goes through if you are still on the older version of alerta you can add this to your config: [alerta] token-prefix = "Key"

allen13 avatar Feb 03 '17 22:02 allen13

Thanks getting this merged in so quickly @nathanielc!

allen13 avatar Feb 07 '17 20:02 allen13

Sorry, speaking about new and old alerta... I actually managed to get kapacitor+alerta running only after I used token-prefix ="Key". before that it was Alerta: Token is invalid error all the time.

And alerta version is 5.0.4 which is the latest and Kapacitor 1.3.3.

It doesn't work with token-prefix = "Bearer" or token-prefix = ""

v-zhuravlev avatar Dec 18 '17 16:12 v-zhuravlev

I agree with @v-zhuravlev. Systems integrating with Alerta should use "Key <api-key>" in the Authorization header, not "Bearer". "Bearer" is reserved for user logins like the web UI and alerta command-line tool. I suggest you change the default token-prefix back to "Key".

satterly avatar Dec 21 '17 14:12 satterly

Whatever the latest default for alerta is should probably be the default here. This is more of an issue with the alerta project changing back and forth.

allen13 avatar Dec 21 '17 14:12 allen13

@allen13 Just for the record, the Alerta authorization header has never changed. It was always "Key" for API keys and "Bearer" for the web UI.

satterly avatar Dec 21 '17 15:12 satterly

Hey, I've made PR because I spend some time why proper tokens are not working with Alerta on latest version of kapacitor (upgrade from 1.2 to 1.4).

Alerta doesn't work with Bearer, so it shouldn't be a default value.

SebastianCzoch avatar Jan 10 '18 19:01 SebastianCzoch

Thanks for notifying me in this thread, much appreciated.

Ping @pommi

emirozer avatar Jan 23 '18 10:01 emirozer

Any update of this or reason it was not merged yet ? Still Alerta's default prefix is Bearer which is wrong and without change of kapacitord's config Alerta integration is broken.

Edke avatar Jun 03 '19 11:06 Edke

I was going to prepare a PR cause I fell into the same trap. Can we get :eyes: on https://github.com/influxdata/kapacitor/pull/1753 and merge it cause the current default in kapacitor.conf is confusing.

lotooo avatar Oct 18 '19 08:10 lotooo

This is confusing, I'm a long time alerta and kapacitor user and I had to change my config to something like that to make it work: (doing that for all those lovely web search engine users)

kapacitor.conf

[alerta]
  enabled = true
  url = "http://alerta:8080/api"
  token = "myToken"
  token-prefix ="Key"
  environment = "Development"
  origin = "kapacitor"

fajfer avatar Nov 06 '19 13:11 fajfer