सामग्रीमा जानुहोस्

The permission model

How a key "app.action" is resolved – and how apps check it.

All permissions are evaluated in one place: customers/rbac.py. Apps never resolve groups themselves; they only call has_perm() or the @require_app_perm() decorator.

Resolving a key

For a key app.action the following applies in order:

  1. The key must be in the catalogue (customers/permissions_config.py) – unknown keys are never allowed.
  2. The module must be active for the company: core modules always, marketplace modules only with an active subscription. This also applies to administrators.
  3. Superusers, tenant and company admins have every key.
  4. Everyone else gets the union of - active, approved group memberships in the company (including active parent groups; the child group overrides the parents, member overrides the group), - personal extra permissions on the company member (permission_flags), - the app's baseline permissions (permissions.py, see Anatomy of a module).

Checking in an app

from django.contrib.auth.decorators import login_required
from customers.permissions import has_perm, require_app_perm

@login_required
@require_app_perm("tasks.access")          # AFTER @login_required
def index(request):
    may_see_all = has_perm(request, "tasks.view_all")
    ...

Cache

The result is cached in Redis, versioned per company: every change to groups, memberships or company members bumps the version, so old entries are invalid at once. The check for booked modules is not cached but applied on every check.

The administrator's view: Groups and permissions.

मद्दत & सहयोग

खोजेको कुरा फेला परेन? प्लेटफर्म र सहायता केन्द्र एक क्लिक टाढा छन्।