Skip to main content
Version: Fleeto

Scope Arrangement & Permission Management

Author(s)

  • SANKET MAL
  • SAYAN MUKHERJEE
  • RESHMI KARAN

Last Updated Date

2024-09-13


SRS References


Version History

VersionDateChangesAuthor
1.02024-09-13Initial draftSANKET 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.)

    EndpointMethodParametersResponseResponse Status Codes
    /api/auth/roledetailsGETroleIdRoleManager200,
    404,
    403,
    500
    /api/auth/role/createorupdatePOSTOperationType (Create or Update) ,
    RoleManager
    Status 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

NoTask NameEstimate (Hours)DependenciesNotes
1Default scopes assign at the time of any new role Creation.6 hours
2Don't update the default scopes at the time of any role update.6 hours
3Modify Get RoleDetails API6 hours
4Database Migration4 hours
5Backend testing for role creation1 hours
6Backend testing for role update1 hours
7Backend testing for get role details2 hours
8Frontend: Grouping based user role show in sidebar3 hours
9Frontend: userrole structure and api changes with fake data call2 hours
10Frontend: show title and description for each scope change in ui3 hours
11Frontend: testing4 hours
12Total38 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

RiskImpactLikelihoodMitigation 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.)