You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classStation(BaseModel):
id: PydanticObjectIdname: strmanagers: list[PydanticObjectId] # List of User ObjectIDclassUser(BaseModel):
id: PydanticObjectIdusername: strrole: RoleEnums01_station=Station(id='S01', name='S01', managers=['U01', 'U02'])
u01_manager=User(id='U01', name='U01', role=RoleEnum.STATION_MANAGER')
I would like to define a policy to allow a manager to get stations which managers field includes the manager's user ID. But I can't make it happen.
My typical inquiry is:
allowed=guard.is_allowed(Inquiry(
action=ActionEnum.GET_STATION,
resource=s01_station.model_dump(), # `model_dump()` converts Pydantic model instance to an dict objectsubject=u01_manager.model_dump(),
))
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I have two Pydantic models,
Station
andUser
:I would like to define a policy to allow a manager to get stations which
managers
field includes the manager's user ID. But I can't make it happen.My typical inquiry is:
What I did so far:
Can anyone help?
Beta Was this translation helpful? Give feedback.
All reactions