Scope Arrangement & Permission Management
Author(s)
- SANKET MAL
- SAYAN MUKHERJEE
- RESHMI KARAN
Last Updated Date
2024-09-13
SRS References
Version History
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.0 | 2024-09-13 | Initial draft | SANKET MAL SAYAN MUKHERJEE RESHMI KARAN |
| ... | ... | ... | ... |
Feature Overview
Objective:
The objective of this feature is to provide a robust system for managing and arranging scope-based permissions within roles. This includes defining how scopes are arranged, how permissions are managed, and how to ensure that certain scopes are non-changeable and assigned by default.
Scope:
This feature covers the arrangement of scopes with proper title , description , grouping and sorting scopes of each group. It also includes defining default and mandatory scopes that cannot be altered once assigned at the time of role creation.
Dependencies:
Requirements
-
Arranging Scope :
- Title: Each scope should have a proper title.
- Description: Provide a detailed description of each scope to ensure that its purpose is well-understood.
- Grouping: Organize scopes into logical groups to simplify management and improve clarity. Each group should have a distinct name and should be used to categorize scopes based on their function or relevance.
- Sorting: Implement a mechanism to order scopes within each group.
-
By default certain scope assign at the time of role creation :
- Default Scopes: These are predefined scopes that are automatically included when a new role is created. The system should ensure that these scopes are included by default and that they cannot be removed or altered by users.
- Ensure that default scopes are applied to all roles at the time of role creation without requiring additional user input.
-
Don't show non changable scope : Implement logic in the backend to filter out non-changeable scopes before sending scope data for the get role details api to the frontend. This will prevent these scopes from being displayed or interacted with by users.
Design Specifications
(Provide detailed design specifications, including UI/UX designs, API interfaces, and any other relevant architectural details.)
-
UI/UX Design:
(Include wireframes, mockups, or links to design files.) -
Data Models:
(Detail the data structures, including database schemas or objects.)public record Scope
{
public Guid ScopeID { get; set; }
public required string ScopeName { get; set; }
public AccessType AccessType { get; set; }//bitmusk
}
public record ScopeDetails : Scope
{
public required string Description { get; set; }
public required string Title { get; set; }
public ScopeGroup GroupName { get; set; }
public int SortOrder { get; set; }
public bool IsDefault { get; set;}
}
public record RoleManagerWithDetails
{
public required Role Role { get; set; }
public List<ScopeDetails> Scopes { get; set; } = new List<ScopeDetails>();
}
public enum ScopeGroup
{
UserManagement,
DealerManagement,
ProductManagement,
DraftOrderManagement,
CustomerManagement,
OrderManagement,
InvoiceManagement,
PaymentManagement,
Analytics,
FileManagement
}
//Change in database
ALTER TABLE Scopes
ADD Description TEXT,
ADD Title TEXT NOT NULL,
ADD GroupName TEXT,
ADD SortOrder INT,
ADD IsDefault BOOLEAN NOT NULL DEFAULT FALSE; -
API Interfaces:
(Define the APIs required for this feature, including endpoints, methods, request/response formats.)Endpoint Method Parameters Response Response Status Codes /api/auth/roledetailsGETroleIdRoleManager200,
404,
403,
500/api/auth/role/createorupdatePOSTOperationType(Create or Update) ,
RoleManagerStatus with Message200,
401,404,409,
500 -
Third-Party Integrations:
-
Workflow:
- Default scopes assign at the time of any new role Creation.
- Don't update the default scopes at the time of any role update.
- At the time of fetching role details don't send default scopes, just send all the scopes other than default scopes.
- At the time of fetching role details send the scopes with proper title, description, grouping and sorting index.
Development Tasks & Estimates
| No | Task Name | Estimate (Hours) | Dependencies | Notes |
|---|---|---|---|---|
| 1 | Default scopes assign at the time of any new role Creation. | 6 hours | ||
| 2 | Don't update the default scopes at the time of any role update. | 6 hours | ||
| 3 | Modify Get RoleDetails API | 6 hours | ||
| 4 | Database Migration | 4 hours | ||
| 5 | Backend testing for role creation | 1 hours | ||
| 6 | Backend testing for role update | 1 hours | ||
| 7 | Backend testing for get role details | 2 hours | ||
| 8 | Frontend: Grouping based user role show in sidebar | 3 hours | ||
| 9 | Frontend: userrole structure and api changes with fake data call | 2 hours | ||
| 10 | Frontend: show title and description for each scope change in ui | 3 hours | ||
| 11 | Frontend: testing | 4 hours | ||
| 12 | Total | 38 hours |
Testing & Quality Assurance
(Outline the testing strategy and quality assurance measures for the feature.)
-
Unit Tests:
- Unit Test for Create Role.
- Unit Test for Update Role.
- Unit Test for Get Role Details.
-
Integration Tests:
- Role creation with default scopes.
- Fetchi role details (excluded non changable scopes)
- Update role without effecting non changable scopes.
- Verify scope grouping and sorting.
-
Acceptance Criteria:
For the feature to be considered complete, the following criteria must be met:- Default scopes are assigned automatically when a new role is created, and they cannot be removed or altered.
- The API excludes default and non-changeable scopes when returning role details.
- Scopes are returned with correct titles, descriptions, groupings, and sorted by SortOrder.
- Users can modify only changeable scopes, and default scopes remain intact after updates.
- Scopes are displayed in logical groups with appropriate sorting in the frontend.
- Default scopes are not visible or editable through the UI in the role management process.
-
Testing Tools:
xUnit
Moq
Deployment Considerations
(Describe any deployment considerations, including environment configurations, feature toggles, or migration steps.)
-
Configuration Changes:
- Database Migration : Add extra columns in tblscopes and insert values for those columns.
- Database Migration : Insert default scopes permission for all roleid in tblrolepermissionmapping.
- Database Schema Changes:
ALTER TABLE Scopes ADD Description TEXT, ADD Title TEXT NOT NULL, ADD GroupName TEXT, ADD SortOrder INT, ADD IsDefault BOOLEAN NOT NULL DEFAULT FALSE;
-
Rollout Plan:
(Outline the plan for rolling out the feature, including any phased releases.)
Risks & Mitigations
| Risk | Impact | Likelihood | Mitigation Strategy |
|---|
Review & Approval
(Include a section for review and approval by stakeholders.)
-
Reviewer:
Abhishak Kumar Roy -
Approval Date:
2024-09-17
Notes
(Add any additional notes or considerations related to the feature development here.)