Skip to content

Conversation

@NShaforostov
Copy link
Collaborator

This PR adds functionality that checks whether module is permitted to launch for the user.

The approach is the following:

  • within the run launched with enabled Module capability, via modules_setup inner script, a configuration file (SitePackage.lua) and auxiliary shell script (CheckPermissions.sh) are being created in the CP_CAP_MODULES_CONFIG_DIR
  • this configuration file contains a hook that is used every time when user loads a module
  • this hook checks:
    • if there is a file permissions.json in the module directory then:
      • if permissions mode in the file is restriction by usernames - then checks whether current user is in the permitted list (in permissions.json)
      • if permissions mode in the file is restriction by locations - then checks whether location of the current user is in the permitted list (in permissions.json)
      • if validation are passed then module is being loaded as usual else launch is being blocked and an error message appears
    • else if no permissions.json in the module directory then module is launched without any additional validations

Additional details:

  • validations are being performed via CheckPermissions.sh shell script that is being launched from module configuration file (SitePackage.lua) and located in the same directory (CP_CAP_MODULES_CONFIG_DIR)
  • name of the current user is obtained from the JWT token ($API_TOKEN)
  • location of the current user is obtained from the user attribute (user_region)

@NShaforostov NShaforostov requested a review from sidoruka October 24, 2025 12:48
(cherry picked from commit 9828eaa)
@sidoruka sidoruka merged commit af265d6 into develop Nov 6, 2025
2 checks passed
@sidoruka sidoruka deleted the modules_check_permissions branch November 6, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants