Api v1.15.0 (#1589)

* fix(chalice): fixed projectKey-APIKey validation logic
This commit is contained in:
Kraiem Taha Yassine 2023-10-27 17:52:40 +02:00 committed by GitHub
parent ff85b086b5
commit 0cfdb02526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -28,8 +28,7 @@ class ProjectAuthorizer:
current_project = projects.get_by_project_key(project_key=value)
if current_project is None:
logger.debug("project not found")
logger.debug(value)
logger.debug(f"unauthorized project {self.project_identifier}:{value}")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="project not found.")
else:
current_project = schemas.CurrentProjectContext(projectId=current_project["projectId"],

View file

@ -29,10 +29,15 @@ class ProjectAuthorizer:
current_project = projects.get_project(tenant_id=current_user.tenant_id, project_id=value)
elif self.project_identifier == "projectKey":
current_project = projects.get_by_project_key(value)
if current_project is not None \
and request.state.authorizer_identity == "jwt" \
and projects.is_authorized(project_id=current_project["projectId"],
tenant_id=current_user.tenant_id,
user_id=user_id):
current_project = None
if current_project is None:
logger.debug("unauthorized project")
logger.debug(value)
logger.debug(f"unauthorized project {self.project_identifier}:{value}")
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="unauthorized project.")
else:
current_project = schemas.CurrentProjectContext(projectId=current_project["projectId"],