19 lines
486 B
Python
19 lines
486 B
Python
from __future__ import annotations
|
|
|
|
from typing import Protocol
|
|
|
|
|
|
class PermissionUser(Protocol):
|
|
is_authenticated: bool
|
|
is_superuser: bool
|
|
|
|
def has_perm(self, permission_name: str) -> bool: ...
|
|
|
|
|
|
def has_store_access(user: PermissionUser, permission_name: str) -> bool:
|
|
"""Authorize NetBox users without relying on the removed ``is_staff`` field."""
|
|
return bool(
|
|
user.is_authenticated
|
|
and (user.is_superuser or user.has_perm(permission_name))
|
|
)
|