add per user group management
Drop the secret from groups, instead set per user access rights to read or write group information.
This commit is contained in:
parent
14f2395fa6
commit
e2a3f0b6fa
3 changed files with 98 additions and 22 deletions
|
|
@ -6,6 +6,7 @@ from typing import (
|
|||
Annotated,
|
||||
Any,
|
||||
ClassVar,
|
||||
Literal,
|
||||
Optional,
|
||||
Type,
|
||||
TypeVar,
|
||||
|
|
@ -283,6 +284,11 @@ class User:
|
|||
imdb_id: str = None
|
||||
name: str = None # canonical user name
|
||||
secret: str = None
|
||||
groups: list[dict[str, str]] = field(default_factory=list)
|
||||
|
||||
def has_access(self, group_id: Union[ULID, str], access: Literal["r", "w"] = "r"):
|
||||
group_id = group_id if isinstance(group_id, str) else str(group_id)
|
||||
return any(g["id"] == group_id and access in g["access"] for g in self.groups)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
@ -291,5 +297,4 @@ class Group:
|
|||
|
||||
id: ULID = field(default_factory=ULID)
|
||||
name: str = None
|
||||
secret: str = None
|
||||
users: list[dict[str, str]] = field(default_factory=list)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue