|
53 | 53 | the environment variable ``CYLC_SITE_CONF_PATH``. |
54 | 54 | """ |
55 | 55 |
|
56 | | -from concurrent.futures import ProcessPoolExecutor |
57 | 56 | import getpass |
58 | 57 | import os |
59 | | -from pathlib import Path, PurePath |
60 | 58 | import sys |
| 59 | +from concurrent.futures import ProcessPoolExecutor |
| 60 | +from pathlib import Path, PurePath |
61 | 61 | from textwrap import dedent |
62 | | -from typing import List, Optional |
| 62 | +from types import SimpleNamespace |
| 63 | +from typing import List, Optional, Union |
63 | 64 |
|
| 65 | +from jupyter_server.extension.application import ExtensionApp |
64 | 66 | from pkg_resources import parse_version |
65 | 67 | from tornado import ioloop |
66 | 68 | from tornado.web import RedirectHandler |
|
76 | 78 | default, |
77 | 79 | validate, |
78 | 80 | ) |
79 | | -from types import SimpleNamespace |
80 | | - |
81 | | -from jupyter_server.extension.application import ExtensionApp |
| 81 | +from traitlets.config.loader import LazyConfigValue |
82 | 82 |
|
83 | 83 | from cylc.flow.network.graphql import ( |
84 | 84 | CylcGraphQLBackend, IgnoreFieldMiddleware |
|
109 | 109 | from cylc.uiserver.websockets.tornado import TornadoSubscriptionServer |
110 | 110 | from cylc.uiserver.workflows_mgr import WorkflowsManager |
111 | 111 |
|
| 112 | + |
112 | 113 | INFO_FILES_DIR = Path(USER_CONF_ROOT / "info_files") |
113 | 114 |
|
114 | 115 |
|
@@ -549,15 +550,26 @@ def set_sub_server(self): |
549 | 550 | auth=self.authobj, |
550 | 551 | ) |
551 | 552 |
|
552 | | - def set_auth(self): |
| 553 | + def set_auth(self) -> Authorization: |
553 | 554 | """Create authorization object. |
554 | 555 | One for the lifetime of the UIServer. |
555 | 556 | """ |
| 557 | + user_auth: Union[LazyConfigValue, dict] = ( |
| 558 | + self.config.CylcUIServer.user_authorization |
| 559 | + ) |
| 560 | + site_auth: Union[LazyConfigValue, dict] = ( |
| 561 | + self.config.CylcUIServer.site_authorization |
| 562 | + ) |
| 563 | + if isinstance(user_auth, LazyConfigValue): |
| 564 | + user_auth = user_auth.to_dict() |
| 565 | + if isinstance(site_auth, LazyConfigValue): |
| 566 | + site_auth = site_auth.to_dict() |
| 567 | + |
556 | 568 | return Authorization( |
557 | 569 | getpass.getuser(), |
558 | | - self.config.CylcUIServer.user_authorization, |
559 | | - self.config.CylcUIServer.site_authorization, |
560 | | - self.log |
| 570 | + user_auth, |
| 571 | + site_auth, |
| 572 | + self.log, |
561 | 573 | ) |
562 | 574 |
|
563 | 575 | def initialize_templates(self): |
|
0 commit comments