keyshade icon indicating copy to clipboard operation
keyshade copied to clipboard

refactor(api): Change Authority to Authorities[] in checkAuthorityOverWorkspace

Open anaskhan28 opened this issue 6 months ago • 2 comments

User description

Description

Changed the authority check from a single Authority to an array of Authorities[] in the checkAuthorityOverWorkspace method. This allows for more flexible permission checks where a user can have multiple authorities.

Fixes #196

Dependencies

No new dependencies were added.

Future Improvements

  • Consider implementing a more granular authority system if needed in the future.
  • Potentially add a caching mechanism for frequently checked authorities to improve performance.

Mentions

@[relevant-team-member] @[project-manager]

Screenshots of relevant screens

N/A - This change is backend-only and does not affect the UI.

Developer's checklist

  • [x] My PR follows the style guidelines of this project
  • [x] I have performed a self-check on my work

If changes are made in the code:

  • [x] I have followed the coding guidelines
  • [x] My changes in code generate no new warnings
  • [ ] My changes are breaking another fix/feature of the project
  • [x] I have added test cases to show that my feature works
  • [ ] I have added relevant screenshots in my PR
  • [ ] There are no UI/UX issues

Documentation Update

  • [x] This PR requires an update to the documentation at docs.keyshade.xyz
  • [ ] I have made the necessary updates to the documentation, or no documentation changes are required.

Note: Please review and update the documentation to reflect the change from Authority to Authorities[].


PR Type

Enhancement, Bug fix


Description

  • Refactored multiple services to change the authority check from a single Authority to an array of Authorities[].
  • Updated logic in AuthorityCheckerService to handle multiple authorities.
  • Improved error messages for unauthorized access across various services.
  • Ensured all relevant service methods now accept and process an array of authorities.

Changes walkthrough 📝

Relevant files
Enhancement
10 files
authority-checker.service.ts
Refactor authority checks to support multiple authorities

apps/api/src/common/authority-checker.service.ts

  • Changed authority parameter to authorities array in multiple methods.
  • Updated logic to check for multiple authorities.
  • Improved error messages for unauthorized access.
  • +77/-79 
    environment.service.ts
    Update environment service to support multiple authorities

    apps/api/src/environment/service/environment.service.ts

  • Updated calls to checkAuthorityOverProject and
    checkAuthorityOverEnvironment to use authorities array.
  • +5/-5     
    event.service.ts
    Update event service to support multiple authorities         

    apps/api/src/event/service/event.service.ts

  • Updated call to checkAuthorityOverWorkspace to use authorities array.
  • +1/-1     
    integration.service.ts
    Update integration service to support multiple authorities

    apps/api/src/integration/service/integration.service.ts

  • Updated calls to checkAuthorityOverWorkspace,
    checkAuthorityOverProject, and checkAuthorityOverEnvironment to use
    authorities array.
  • +10/-10 
    project.service.ts
    Update project service to support multiple authorities     

    apps/api/src/project/service/project.service.ts

  • Updated calls to checkAuthorityOverWorkspace and
    checkAuthorityOverProject to use authorities array.
  • +12/-12 
    secret.service.ts
    Update secret service to support multiple authorities       

    apps/api/src/secret/service/secret.service.ts

  • Updated calls to checkAuthorityOverProject,
    checkAuthorityOverEnvironment, and checkAuthorityOverSecret to use
    authorities array.
  • +9/-9     
    change-notifier.socket.ts
    Update change notifier to support multiple authorities     

    apps/api/src/socket/change-notifier.socket.ts

  • Updated calls to checkAuthorityOverWorkspace,
    checkAuthorityOverProject, and checkAuthorityOverEnvironment to use
    authorities array.
  • +3/-3     
    variable.service.ts
    Update variable service to support multiple authorities   

    apps/api/src/variable/service/variable.service.ts

  • Updated calls to checkAuthorityOverProject,
    checkAuthorityOverEnvironment, and checkAuthorityOverVariable to use
    authorities array.
  • +9/-9     
    workspace-role.service.ts
    Update workspace role service to support multiple authorities

    apps/api/src/workspace-role/service/workspace-role.service.ts

  • Updated calls to checkAuthorityOverWorkspace to use authorities array.

  • +5/-5     
    workspace.service.ts
    Update workspace service to support multiple authorities 

    apps/api/src/workspace/service/workspace.service.ts

  • Updated calls to checkAuthorityOverWorkspace to use authorities array.

  • +12/-12 

    💡 PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    anaskhan28 avatar Jul 28 '24 17:07 anaskhan28