Ana içeriğe geç

Yetkilendirme (RBAC)

İzin Yapısı

95 granüler izin, action:resource formatında:

read:device, write:device, delete:device, control:device
read:gateway, write:gateway, delete:gateway
read:alarm, ack:alarm, close:alarm
upload:firmware, initiate:ota, batch:ota
request:loto, approve:loto, apply:loto, release:loto
export:measurement, export:report
...

Önceden Tanımlı Roller

Rolİzin SayısıYetkiler
admin54Tüm CRUD + kontrol + silme + admin
operator33Okuma + yazma + kontrol (silme yok)
viewer11Sadece okuma + rapor export

Kullanım

@router.get("/devices/{device_id}")
async def get_device(
device_id: UUID,
user: CurrentUser = require_permissions(
[Permission.READ_DEVICE],
scope_resolver=scope_device_from_path("device_id")
)
):
...

Scope-Based Access

Scope resolver fonksiyonları, kaynağın belirli bir kiracıya ait olduğunu doğrular:

  • scope_region_from_path() — region_id path param
  • scope_subregion_from_path() — subregion_id
  • scope_gateway_from_path() — gateway_id
  • scope_device_from_path() — device_id
  • scope_alarm_from_path() — alarm_id

Superuser

is_superuser=True olan kullanıcılar tüm izinlere otomatik sahiptir. Scope kontrolü yine de uygulanır.