{"id":21202,"library":"edx-rbac","title":"edx-rbac","description":"Library for managing role-based access control (RBAC) for Django applications, used within the Open edX ecosystem. Current version: 3.0.0 (2025). Release cadence: sporadic, with minor and patch releases every few months.","status":"active","version":"3.0.0","language":"python","source_language":"en","source_url":"https://github.com/openedx/edx-rbac","tags":["rbac","django","openedx","authorization","roles"],"install":[{"cmd":"pip install edx-rbac","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for Django integration","package":"django","optional":false},{"reason":"Used for JWT token decoding in role verification","package":"PyJWT","optional":false},{"reason":"Common utilities for Open edX Django apps","package":"edx-django-utils","optional":false}],"imports":[{"note":"","wrong":"","symbol":"RoleAssignment","correct":"from edx_rbac.models import RoleAssignment"},{"note":"","wrong":"","symbol":"user_has_role","correct":"from edx_rbac.utils import user_has_role"},{"note":"","wrong":"","symbol":"get_user_role_permissions","correct":"from edx_rbac.utils import get_user_role_permissions"}],"quickstart":{"code":"from django.contrib.auth.models import User\nfrom edx_rbac.models import RoleAssignment\nfrom edx_rbac.utils import user_has_role\n\n# Create a user and assign a role\nuser = User.objects.create_user('testuser', 'test@example.com', 'password')\nRoleAssignment.objects.create(user=user, role='admin', context='default')\n\n# Check if user has a role\nhas_role = user_has_role(user, 'admin')\nprint(f'User has admin role: {has_role}')\n","lang":"python","description":"Create a user, assign a role, and verify role existence."},"warnings":[{"fix":"Upgrade Python to 3.12 or later, then pin edx-rbac>=3.0.0.","message":"Version 3.0.0 drops Python 3.11 support. Upgrade to Python 3.12+.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Upgrade Python to 3.9+.","message":"Version 2.0.0 drops Python 3.8 support.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Change imports to edx_rbac.utils.","message":"Do not import from edx_rbac.helpers; that module is deprecated and will be removed. Use edx_rbac.utils instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always provide a meaningful context when creating RoleAssignment objects.","message":"The default RoleAssignment model requires a valid `context` field; using an empty string may cause unexpected behavior.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change import to: from edx_rbac.utils import get_user_role_permissions","cause":"Incorrect import path from edx_rbac instead of edx_rbac.utils.","error":"ImportError: cannot import name 'get_user_role_permissions' from 'edx_rbac'"},{"fix":"Use: from edx_rbac.models import RoleAssignment","cause":"Trying to import RoleAssignment from the package root instead of edx_rbac.models.","error":"AttributeError: module 'edx_rbac' has no attribute 'RoleAssignment'"},{"fix":"Provide the role string: user_has_role(user, 'admin')","cause":"Called user_has_role(user) without specifying role.","error":"TypeError: user_has_role() missing 1 required positional argument: 'role'"},{"fix":"Add RBAC_BACKEND to settings, e.g.: RBAC_BACKEND = 'edx_rbac.backends.RoleBackend'","cause":"Missing required Django setting for RBAC.","error":"django.core.exceptions.ImproperlyConfigured: The RBAC_BACKEND setting is not configured."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}