Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Role Based Access Control (RBAC) #6911

Open
mdadul opened this issue Aug 31, 2024 · 1 comment
Open

Role Based Access Control (RBAC) #6911

mdadul opened this issue Aug 31, 2024 · 1 comment
Labels
project Project request reviewed request reviewed and will potentially be acted on during roadmap migration.

Comments

@mdadul
Copy link

mdadul commented Aug 31, 2024

What Roadmap is this project for?

Backend Development

Project Difficulty

Intermediate

Add Project Details

Implement a Role-Based Access Control system for an existing blogging platform to manage user permissions and access to various features and content.

Goals

  • Understand and implement RBAC concepts
  • Enhance security and access management of a blogging platform
  • Learn to integrate authentication and authorization mechanisms
  • Practice creating and managing user roles and permissions

Requirements

1. User Roles: Implement the following user roles:

  • Admin: Full access to all features
  • Editor: Can create, edit, and delete their own posts and others' posts
  • Author: Can create, edit, and delete their own posts
  • Commenter: Can read posts and add comments
  • Reader: Can only read posts

2. Authentication System

  • Implement a secure login and registration system
  • Use JWT (JSON Web Tokens) or session-based authentication

3. Authorization System

  • Create a middleware to check user roles and permissions for each request
  • Implement route protection based on user roles

4. User Management

  • Allow admins to create, update, and delete user accounts
  • Enable admins to assign and change user roles

5. Post Management

  • Implement CRUD operations for blog posts with role-based restrictions
  • Allow authors and editors to manage their posts
  • Restrict post deletion to admins, editors, and post owners

6. Comment System

  • Implement a comment system with role-based restrictions
  • Allow commenters and above roles to add comments
  • Allow comment owners and admins to delete comments

7. API Endpoints
Create the following API endpoints with proper role-based access:

User Management:

POST /api/users (Admin only)
GET /api/users (Admin only)
PUT /api/users/:id (Admin only)
DELETE /api/users/:id (Admin only)

Authentication:

POST /api/auth/register
POST /api/auth/login
POST /api/auth/logout

Post Management:

POST /api/posts (Author, Editor, Admin)
GET /api/posts (All roles)
GET /api/posts/:id (All roles)
PUT /api/posts/:id (Post owner, Editor, Admin)
DELETE /api/posts/:id (Post owner, Editor, Admin)

Comment Management:

POST /api/posts/:id/comments (Commenter and above)
GET /api/posts/:id/comments (All roles)
DELETE /api/posts/:id/comments/:commentId (Comment owner, Admin)

8. Error Handling

  • Implement proper error handling for unauthorized access attempts
  • Return appropriate HTTP status codes (e.g., 403 Forbidden, 401 Unauthorized)

Tech Stack Suggestions

You are free to choose the programming language and database of your choice. Actual decisions for the database schema, API endpoints, and other implementation details are up to you. However, you should consider the following constraints:

  • Database: Use a relational database to store user data, workout plans, and exercise data.
  • API: Develop a RESTful API to interact with the database.
  • Security: Implement JWT authentication to secure the API endpoints.
  • Testing: Write unit tests to ensure the correctness of your code.
  • Documentation: Learn about OpenAPI Specs. Document your API endpoints and provide examples of how to use them.

Bonus Features

  • Implement password reset functionality
  • Add email verification for new user registrations
  • Implement rate limiting for API endpoints
  • Add unit and integration tests for the RBAC system
@dansholds
Copy link
Contributor

Very thorough @mdadul thank you!

@dansholds dansholds added project Project request reviewed request reviewed and will potentially be acted on during roadmap migration. labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project Project request reviewed request reviewed and will potentially be acted on during roadmap migration.
Projects
None yet
Development

No branches or pull requests

2 participants