15 lines
367 B
Python
15 lines
367 B
Python
from __future__ import annotations
|
|
|
|
from typing import Dict
|
|
|
|
|
|
class RBAC:
|
|
def __init__(self):
|
|
self.roles: Dict[str, set[str]] = {}
|
|
|
|
def add_role(self, role: str, permissions: list[str]) -> None:
|
|
self.roles[role] = set(permissions)
|
|
|
|
def has_permission(self, role: str, perm: str) -> bool:
|
|
return perm in self.roles.get(role, set())
|