root: fix prometheus path in ServiceMonitor, return WWW-Authenticate header so basic auth is sent
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
from base64 import b64encode
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import Http404, HttpRequest, HttpResponse
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.views import View
|
||||
from django_prometheus.exports import ExportToDjangoView
|
||||
|
||||
@ -18,6 +18,8 @@ class MetricsView(View):
|
||||
expected = b64encode(str.encode(credentials)).decode()
|
||||
|
||||
if auth_type != "Basic" or credentials != expected:
|
||||
raise Http404
|
||||
response = HttpResponse(status=401)
|
||||
response['WWW-Authenticate'] = 'Basic realm="passbook-monitoring"'
|
||||
return response
|
||||
|
||||
return ExportToDjangoView(request)
|
||||
|
Reference in New Issue
Block a user