abhish1227 / abhish1227/HospitalDB_Spring

Feature Request: Add Role-Based Authentication

Đang mở
#1 3 bình luận 0 reaction 1 người được giao Được giao cho @abhish1227 Xem trên GitHub
enhancement good first issue help wanted
Ngôn ngữ chính
Java
Star
1
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### **Description**
Implement role-based access control (RBAC) to restrict access to specific endpoints based on user roles (e.g., ADMIN, DOCTOR, PATIENT). This will enhance security and allow fine-grained permission management across the system.

### **Motivation**
Currently, all authenticated users have equal access to protected endpoints. Introducing roles will:
- Prevent unauthorized access to sensitive operations
- Enable scalable permission management
- Align with real-world hospital workflows (e.g., only doctors can update medical records)

### Proposed Changes:
- Add a role field to the User entity (e.g., Enum or String)
- Assign roles during registration or via admin panel
- Update SecurityFilterChain to restrict endpoints using .hasRole("ROLE_NAME")

Example:
```
.requestMatchers("/doctors/admin/**").hasRole("DOCTOR")
.requestMatchers("/patients/admin/**").hasRole("ADMIN")
```
### Acceptance Criteria:
- Users can only access endpoints permitted by their role
- Unauthorized access returns 403 Forbidden
- Role assignment is clearly documented and testable

### Additional Notes:
- Consider using Spring Security’s GrantedAuthority and UserDetailsService for extensibility
- Update README with role-based access documentation once implemented

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.