api: properly compute authorization based on ccchh role

This commit is contained in:
lilly 2026-05-14 16:41:16 +02:00
commit bf0c085739
Signed by: lilly
SSH key fingerprint: SHA256:y9T5GFw2A20WVklhetIxG1+kcg/Ce0shnQmbu1LQ37g
3 changed files with 10 additions and 8 deletions

View file

@ -33,17 +33,18 @@ class CurrentUser(BaseModel):
@property
def ccchh_roles(self) -> List[str]:
return []
return getattr(self.id_token, "ccchh-roles", [])
@property
def may_operate_locks(self) -> bool:
return True
return "intern@" in self.ccchh_roles
class UserStatus(BaseModel):
is_authorized: bool
guaranteed_session_until: Optional[datetime]
username: Optional[str]
guaranteed_session_until: datetime
username: str
ccchh_roles: List[str]
class LockStatus(BaseModel):