Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DRF Custom Roles and Permissions | Role-Based Access Control (RBAC) in Django Rest Framework

⭐ Overview

This repository demonstrates how to implement Role-Based Access Control (RBAC) using Django Rest Framework (DRF). It covers the creation of custom roles (admin, doctor, staff, patient) and object-level permissions, allowing fine-grained control over API endpoints. The project provides fully functional APIs for creating users, managing staff, and assigning permissions dynamically.

🚀 Key Features

  • Dynamic Role Management – Admin, Doctor, Staff, and Patient roles.
  • Custom Permission Classes – Restrict API access based on user roles.
  • Object-Level Permissions – Control access to specific objects (e.g., appointments).
  • Token Authentication – Secure API endpoints with DRF’s token authentication.
  • API Endpoints for Staff Management – Easily create staff and assign permissions dynamically.
  • Permission Inheritance – Staff permissions are inherited from the doctor role they are linked to.

📚 Topics Covered

  • Django Custom User Model
  • DRF ViewSets and Actions
  • Custom Permissions (BasePermission)
  • One-to-One and Foreign Key Relationships
  • Group and User Permissions with Django’s Built-in Auth

⚙️ Installation

# Clone the repository
git clone https://github.com/boxabhi/Django-DRF-Custom-Roles-and-Permissions-Role-Based-Access-Control-RBAC-with-Django-Rest-Framework

# Navigate to the project directory
cd drf-custom-roles-permissions

# Create and activate virtual environment
python -m venv env
source env/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run migrations
python manage.py migrate

# Create a superuser
python manage.py createsuperuser

# Run the development server
python manage.py runserver

📄 License

MIT License. Feel free to use this project in your applications.

🤝 Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

📫 Contact

For questions or collaborations, feel free to reach out via LinkedIn. https://www.linkedin.com/in/gupta-abhijeet/ https://www.instagram.com/_abhijeetgupta/reels/

📈 Keywords (SEO Optimization)

Django DRF custom roles, DRF custom permissions, Django role-based access control, Django dynamic roles API, Django RBAC tutorial, DRF object-level permissions, Django Rest Framework custom auth, DRF admin doctor staff patient roles.

About

A comprehensive guide and implementation of custom roles and permissions in Django Rest Framework (DRF). This project demonstrates how to create dynamic role-based access control (RBAC) for admin, doctor, staff, and patient users. Includes API endpoints, custom permission classes, and serializers to manage users, roles permissions in DRF.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages