add metrics_authentication decorator to /metrics API

This commit is contained in:
tuhina2020
2018-10-07 13:38:32 +05:30
parent cff066a7be
commit b0b7e8d25d
4 changed files with 18 additions and 0 deletions

View File

@@ -247,6 +247,14 @@ def admin_only(self):
if user is None or not user.admin:
raise web.HTTPError(403)
@auth_decorator
def metrics_authentication(self):
"""Decorator for restricting access to metrics"""
user = self.get_current_user()
authenticate_prometheus = self.authenticate_prometheus()
if user is None and not user.authenticate_prometheus:
raise web.HTTPError(403)
# Token utilities