fix: rn takes org id instead of name
All checks were successful
ci / lint_and_test (push) Successful in 16s
All checks were successful
ci / lint_and_test (push) Successful in 16s
This commit is contained in:
parent
d5854cc2c4
commit
7804816a1a
3 changed files with 15 additions and 13 deletions
|
|
@ -25,7 +25,7 @@ from psycopg.errors import UniqueViolation
|
|||
from src.iam.exceptions import GroupNotFoundException
|
||||
from src.organisation.dependencies import org_model_body_dependency
|
||||
from src.organisation.exceptions import OrgNotFoundException
|
||||
from src.schemas import GroupSummary, OrgSummary, ResourceName
|
||||
from src.schemas import GroupSummary, OrgSummary
|
||||
from src.service.dependencies import service_model_body_dependency
|
||||
from src.exceptions import (
|
||||
ConflictException,
|
||||
|
|
@ -118,7 +118,7 @@ async def can_act_on_resource(
|
|||
"""
|
||||
response = {
|
||||
"allowed": False,
|
||||
"rn": ResourceName(organisation="", service="", resource=""),
|
||||
"rn": request_model.rn,
|
||||
"action": "",
|
||||
"user": {"id": 0, "email": ""},
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ async def can_act_on_resource(
|
|||
rn = request_model.rn
|
||||
action = request_model.action
|
||||
user_id = user_claims["db_id"]
|
||||
rn_org = rn.organisation
|
||||
rn_org = rn.organisation_id
|
||||
rn_service = rn.service
|
||||
rn_resource = rn.resource
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ async def can_act_on_resource(
|
|||
.join(UserGroups, UserGroups.group_id == Group.id)
|
||||
.join(User, User.id == UserGroups.user_id)
|
||||
.filter(User.id == user_id)
|
||||
.filter(Org.name == rn_org)
|
||||
.filter(Org.id == rn_org)
|
||||
.filter(Service.name == rn_service)
|
||||
.filter(Perm.resource == rn_resource)
|
||||
.filter(Perm.action == action)
|
||||
|
|
@ -154,7 +154,8 @@ async def can_act_on_resource(
|
|||
response["allowed"] = True
|
||||
else:
|
||||
response["allowed"] = False
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
response["allowed"] = False
|
||||
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ class ServiceSummary(CustomBaseModel):
|
|||
name: str
|
||||
|
||||
|
||||
class ResourceName(ServiceNameMixin):
|
||||
organisation: str
|
||||
class ResourceName(ServiceNameMixin, OrgIDMixin):
|
||||
resource: str
|
||||
instance: Optional[str] = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue