HTTP 401 on creation / deletion silence after enabling base auth in proxy mode

This issue has been tracked since 2022-02-02.

Karma 0.94
Alertmanager 0.23 (http. no auth)

Simple configration;

alertmanager:
servers:
- name: alertmananager
uri: <secret_uri>
proxy: true
cors:
credentials: omit

authentication:
basicAuth:
users:
- username: test
password: test

history:
rewrite:
- source: '(.*)'
uri: <secret2_uri>
tls:
insecureSkipVerify: true

log:
config: true
level: debug
format: text
requests: true
timestamp: true

receivers:
keep: ["alert"]
strip: ["alertmananger-bot"]

Run karma and test UI:

1. Trying auth:

Browser show auth window on entry - OK.
image
After enter of login and password karma show main UI - OK
window with auth username and version:
image
overview:
image

2. Create new silence

Find active alert
image

Setup selince:
image

After submit, open alertmanager ui and check createtion of silince - NOK

karma | 09:45:35 msg="Request completed" address=10.1.180.31:61573 bytes=0 code=401 duration="610.628µs" method=POST path=/proxy/alertmanager/alertmananager/api/v2/silences

in logs i see request with code 401 reply, but karma UI show green OK sign - NOK
image

3. Trying delete exist silence

Find active suppressed
image
Setup deletetion and confirm
image
karma UI show green OK after confirm - NOK

check logs:

karma | 09:54:26 msg="Request completed" address=10.1.180.31:50420 bytes=0 code=401 duration="336.457µs" method=DELETE path=/proxy/alertmanager/alertmananager/api/v2/silence/617b7e7b-e422-49c1-885f-7b4748ead1a3

check alertmanager ui for silence status
Slince 617b7e7b-e422-49c1-885f-7b4748ead1a3 still active - NOK
image

When i disable basic auth in karma, creation and deletetion working fine.

Quick test on Karma 0.95 - similar behavior

Maybe we have some configuration error? Thank you.

prymitive wrote this answer on 2022-02-02

Why do you have credentials: omit set?
I think your browser is stripping auth information from requests because of it. Try removing:

cors:
  credentials: omit
erachenko23 wrote this answer on 2022-02-03

We set this parameter because in mode proxy: false (or parameter exists) on create silence wee seen this error.

image

We make full retest cycle after applying recommendation: creating and deleteting silence with basic auth work fine.

Thank a lot!!

But i'm think then request end with 401 error karma ui must show error notification instead success. It's minor bug.

prymitive wrote this answer on 2022-02-03

#3948 should fix 401 handling

More Details About Repo
Owner Name prymitive
Repo Name karma
Full Name prymitive/karma
Language TypeScript
Created Date 2018-09-09
Updated Date 2023-03-17
Star Count 1921
Watcher Count 33
Fork Count 166
Issue Count 2

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date