Skip to content

Commit

Permalink
#739 incognito fix - throw 401 unauthorized without token
Browse files Browse the repository at this point in the history
  • Loading branch information
D-GopalKrishna committed Dec 25, 2023
1 parent 7d3ead3 commit 071f56e
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ def clone(self, workspace_id):

def is_authorized(self, workspace):
current_user_id = keycloak_user_id()
if not current_user_id:
return False
return workspace and (workspace.publicable or
(workspace.user_id and workspace.user_id == current_user_id) or
(get_auth_client().user_has_realm_role(user_id=current_user_id, role="administrator")))
Expand Down Expand Up @@ -299,6 +301,8 @@ def to_dao(cls, d: dict) -> TWorkspaceEntity:
def get(self, id_):

workspace: Workspace = super().get(id_)
if not self.is_authorized(workspace):
raise NotAuthorized()

if any(wr.status == ResourceStatus.P for wr in workspace.resources):
fake_path = f"Importing resources"
Expand Down

0 comments on commit 071f56e

Please sign in to comment.