Skip to content

Commit fb443d3

Browse files
authored
Merge pull request jupyter#5974 from blairdrummond/prometheus-auth-default
Allow /metrics by default if auth is off
2 parents ccb2d18 + 2712dc4 commit fb443d3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

notebook/notebookapp.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,21 @@ def _update_server_extensions(self, change):
15841584
"""
15851585
).tag(config=True)
15861586

1587+
@default('authenticate_prometheus')
1588+
def _default_authenticate_prometheus(self):
1589+
""" Authenticate Prometheus by default, unless auth is disabled. """
1590+
auth = bool(self.password) or bool(self.token)
1591+
if auth is False:
1592+
self.log.info(_("Authentication of /metrics is OFF, since other authentication is disabled."))
1593+
return auth
1594+
1595+
@observe('authenticate_prometheus')
1596+
def _update_authenticate_prometheus(self, change):
1597+
newauth = change['new']
1598+
if self.authenticate_prometheus is True and newauth is False:
1599+
self.log.info(_("Authentication of /metrics is being turned OFF."))
1600+
self.authenticate_prometheus = newauth
1601+
15871602
# Since use of terminals is also a function of whether the terminado package is
15881603
# available, this variable holds the "final indication" of whether terminal functionality
15891604
# should be considered (particularly during shutdown/cleanup). It is enabled only

0 commit comments

Comments
 (0)