rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush-lib] Support access parameter for each project configuration

Open pedro-gomes-92 opened this issue 9 months ago • 3 comments

Summary

Restricts a package to be used according to its access restrictions.

Details

Package maintainers often need enhanced control and insight into their projects. By introducing a new parameter named access for rush projects, developers gain the ability to limit the visibility of their projects. This feature ensures that unauthorised developers do not install the projects when they are not supposed to.

Currently the parameter provides 3 values:

  • public (default): project can be accessed by any local package (e.g. core arch libraries).
  • protected: project can only be accessed by the same subspace local package (e.g. team libraries)
  • private: project cannot be accessed by others (e.g. standard application)

Example

CleanShot 2025-02-10 at 15 21 06@2x

P1 has protected access restrictions and is being used by P2 and P3. P1 and P2 belongs to the same subspace S1, while P3 belongs to the subspace S2. Since P1 is restricted to only be installed by packages from S1, rush install will fail.

// rush.json
{
  ...,
  "projects": [
     {
       "packageName": "P1",
       "projectFolder": "packages/p1",
       "subspaceName": "S1",
       "access": "protected"
     },
     {
       "packageName": "P2",
       "projectFolder": "packages/p2",
       "subspaceName": "S1"
     },
     {
       "packageName": "P3",
       "projectFolder": "packages/p3",
       "subspaceName": "S2"
     },
  ]
}

How it was tested

  • Create a repository with subspaces enabled: https://rushjs.io/pages/advanced/subspaces/
  • Create 2 subspaces (e.g. default, S1)
  • Create 2 projects (e.g. P1 and P2) inside of default subspace and 1 project (e.g. P3) inside of S1
  • Add P1 as a local dependency of P2 and P3
  • Update rush.json with { "access": "protected" } for P1 configuration (or private)
  • Run rush install --subspace S2

The error message will appear and the installation will fail:

ERROR: P3 doesn't have permissions to access P1.
Please remove this dependency or update the rush.json access rights.

Impacted documentation

https://rushjs.io/pages/configs/rush_json

pedro-gomes-92 avatar Feb 10 '25 08:02 pedro-gomes-92