Skip to content

Commit 2d11445

Browse files
committed
Address PR feedback on consumer class see HEA-752
1 parent 0e74c37 commit 2d11445

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

apps/common/consumers.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@ async def connect(self):
2020
logger.error("Authentication required")
2121
raise DenyConnection("Authentication required")
2222

23-
if not self.scope["user"].has_perm("common.access_dagster_ui"):
24-
logger.error(f"User {self.scope['user'].username} lacks permission")
23+
perm = "common.access_dagster_ui"
24+
if not self.scope["user"].has_perm(perm):
25+
logger.error(
26+
f"User {self.scope['user'].username} lacks permission {perm} for accessing {self.scope['path']}"
27+
)
2528
raise DenyConnection("Permission denied")
2629

2730
logger.info(f"User {self.scope['user'].username} authenticated")
2831

2932
# Build upstream URL
3033
dagster_url = os.environ.get("DAGSTER_WEBSERVER_URL", "http://localhost:3000")
31-
dagster_prefix = os.environ.get("DAGSTER_WEBSERVER_PREFIX", "")
34+
dagster_prefix = os.environ.get("DAGSTER_WEBSERVER_PREFIX", "pipelines")
3235

3336
path = self.scope["path"]
34-
if path.startswith("/pipelines/"):
35-
path = path[len("/pipelines/") :]
37+
if path.startswith(f"/{dagster_prefix}/"):
38+
path = path[len(f"/{dagster_prefix}/") :]
3639

3740
# Convert http to ws
3841
if dagster_url.startswith("https://"):
@@ -45,7 +48,6 @@ async def connect(self):
4548
target_url = f"{ws_url}/{dagster_prefix}/{path}"
4649
else:
4750
target_url = f"{ws_url}/{path}"
48-
4951
# Add query string
5052
if self.scope.get("query_string"):
5153
target_url += f"?{self.scope['query_string'].decode()}"

0 commit comments

Comments
 (0)