Skip to content

Commit

Permalink
Merge pull request #5974 from blairdrummond/prometheus-auth-default
Browse files Browse the repository at this point in the history
Allow /metrics by default if auth is off
  • Loading branch information
kevin-bates authored Feb 8, 2021
2 parents ccb2d18 + 2712dc4 commit fb443d3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,21 @@ def _update_server_extensions(self, change):
"""
).tag(config=True)

@default('authenticate_prometheus')
def _default_authenticate_prometheus(self):
""" Authenticate Prometheus by default, unless auth is disabled. """
auth = bool(self.password) or bool(self.token)
if auth is False:
self.log.info(_("Authentication of /metrics is OFF, since other authentication is disabled."))
return auth

@observe('authenticate_prometheus')
def _update_authenticate_prometheus(self, change):
newauth = change['new']
if self.authenticate_prometheus is True and newauth is False:
self.log.info(_("Authentication of /metrics is being turned OFF."))
self.authenticate_prometheus = newauth

# Since use of terminals is also a function of whether the terminado package is
# available, this variable holds the "final indication" of whether terminal functionality
# should be considered (particularly during shutdown/cleanup). It is enabled only
Expand Down

0 comments on commit fb443d3

Please sign in to comment.