File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 249249 r'^nodes/(?P<node>[a-zA-Z0-9-]+)/proxy/metrics(?:/(?P<metrics>[^/]+))?/?$' ,
250250 views .ProxyMetricsView .as_view ()),
251251 # prometheus
252- re_path (r'^prometheus/(?P<path>.+)/?$' , views .PrometheusProxy .as_view ()),
252+ re_path (
253+ r'^prometheus/(?P<username>[\w.@+-]+)/(?P<path>.+)/?$' , views .PrometheusProxy .as_view ()),
253254 # tokens
254255 re_path (r'^tokens/?$' , views .TokenViewSet .as_view ({'get' : 'list' })),
255256 re_path (r"^tokens/(?P<pk>[-_\w]+)/?$" , views .TokenViewSet .as_view ({'delete' : 'destroy' })),
Original file line number Diff line number Diff line change @@ -1336,9 +1336,9 @@ class PrometheusProxy(View):
13361336 timeout = aiohttp .ClientTimeout (total = 30 , connect = 10 , sock_read = 15 )
13371337 authentication = authentication .DryccAuthentication ()
13381338
1339- async def proxy (self , request , path ):
1339+ async def proxy (self , request , username , path ):
13401340 auth = await database_sync_to_async (self .authentication .authenticate )(request )
1341- if not auth or len (auth ) != 2 or not isinstance ( auth [0 ], User ) :
1341+ if not auth or len (auth ) != 2 or not auth [0 ]. username != username :
13421342 return JsonResponse ({'error' : 'access denied' }, status = 403 )
13431343 if auth [0 ].is_superuser or auth [0 ].is_staff :
13441344 path = f"/select/0/prometheus/{ path } "
You can’t perform that action at this time.
0 commit comments