-
Notifications
You must be signed in to change notification settings - Fork 1
Add basic password auth to the reduction dashboard #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,13 +54,16 @@ def __init__( | |
| log_level: int = logging.INFO, | ||
| dashboard_name: str, | ||
| port: int = 5007, | ||
| basic_auth_password: str | None = None, | ||
| basic_auth_cookie_secret: str | None = None, | ||
| ): | ||
| name = f'{instrument}_{dashboard_name}' | ||
| super().__init__(name=name, log_level=log_level) | ||
| self._instrument = instrument | ||
| self._port = port | ||
| self._dev = dev | ||
|
|
||
| self._basic_auth_password = basic_auth_password | ||
| self._basic_auth_cookie_secret = basic_auth_cookie_secret | ||
| self._exit_stack = ExitStack() | ||
| self._exit_stack.__enter__() | ||
|
|
||
|
|
@@ -258,6 +261,8 @@ def server(self): | |
| show=False, | ||
| autoreload=False, | ||
| dev=self._dev, | ||
| basic_auth=self._basic_auth_password, | ||
| cookie_secret=self._basic_auth_cookie_secret, | ||
|
Comment on lines
+264
to
+265
|
||
| ) | ||
|
|
||
| def _start_impl(self) -> None: | ||
|
|
@@ -276,6 +281,8 @@ def run_forever(self) -> None: | |
| show=False, | ||
| autoreload=True, | ||
| dev=self._dev, | ||
| basic_auth=self._basic_auth_password, | ||
| cookie_secret=self._basic_auth_cookie_secret, | ||
| ) | ||
| except KeyboardInterrupt: | ||
| self._logger.info("Keyboard interrupt received, shutting down...") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,13 +16,23 @@ | |
| class ReductionApp(DashboardBase): | ||
| """Reduction dashboard application.""" | ||
|
|
||
| def __init__(self, *, instrument: str = 'dummy', dev: bool = False, log_level: int): | ||
| def __init__( | ||
| self, | ||
| *, | ||
| instrument: str = 'dummy', | ||
| dev: bool = False, | ||
| log_level: int, | ||
| basic_auth_password: str | None = None, | ||
| basic_auth_cookie_secret: str | None = None, | ||
| ): | ||
| super().__init__( | ||
| instrument=instrument, | ||
| dev=dev, | ||
| log_level=log_level, | ||
| dashboard_name='reduction_dashboard', | ||
| port=5009, # Default port for reduction dashboard | ||
| basic_auth_password=basic_auth_password, | ||
| basic_auth_cookie_secret=basic_auth_cookie_secret, | ||
| ) | ||
| self._logger.info("Reduction dashboard initialized") | ||
|
|
||
|
|
@@ -39,7 +49,9 @@ def create_main_content(self) -> pn.viewable.Viewable: | |
|
|
||
|
|
||
| def get_arg_parser() -> argparse.ArgumentParser: | ||
| return Service.setup_arg_parser(description='ESSlivedata Dashboard') | ||
| return Service.setup_arg_parser( | ||
| description='ESSlivedata Dashboard', dashboard_auth=True | ||
| ) | ||
|
Comment on lines
51
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since auth is only for the dashboard, it might make more sense to add the options here before returning, instead of adding a flag to the to the generic |
||
|
|
||
|
|
||
| def main() -> None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command-line arguments for passwords can be visible in process lists and shell history. Consider adding a warning in the help text to recommend using the environment variable LIVEDATA_BASIC_AUTH_PASSWORD instead for better security.