How to use the App-Model's "Permission" field?

Hey Guys,

There is this field in the SME App-Model editor on modules called “Permission”. As the description says, it is used to show/hide modules base on users permissions.

But when I define a role on there, the module is always hidden, even if the user has the same role assigned. I also tried the username, without success. And I could not find any documentation about the field.

Am I doing something wrong, and can someone help me?

Hey @raffael-broad-linden,

thanks for using Discourse.

I talked with Denise Vogel, so I assume you tried it in the Project Template. I was able to replicate your issue and found bug that we will fix as soon as we can. That unfortunately means, that it is not possible to use ‘Permissions’ in the models deployed to the Project Template at the moment.

You understand the “Permissions” correctly. It works properly in the Preview App (part of the Installer) and if you add the ‘role’ to the ‘Permission’, only users with this role will be able to see the given module.

I will post an update once we have this issue fixed.

Hi @peter-sheer-arch

Thank you very much for the clarification!

We indeed initially used the project template. And just to clarify, since there is this bug, is the project template the recommended way to start a new A12 project?

Could you maybe explain the bug a little more, because I don’t understand what the difference between the PAC and the project template is in that regard?

Maybe we can implement a workaround / the thing that makes it work in the PAC in our project too?

Hi @raffael-broad-linden,

yes, the Project Template is still recommended, it can offer a lot from the code, structure and example point of view.

First the difference between PAC and PT:

  • Preview App is more ready-to-use and tailored to work with the SME, which brings some limitations in code and extendability.
  • Project Template is a codebase template with some code examples and structure example, ready to be extended, modified and tweaked according to the project and its developers needs. That might, like in this case, bring some misalignments with the PAC approach, that we try to solve rapidly.

Second, the bug:

  • It is related to other features that we implemented in the Project Template and the ‘Permission’ support was waiting to be implemented after these features. So it is more of a know issue, than a bug, as my more senior colleagues explained.
  • The fix/implementation includes adding a UAA Authentication user rights logic to the client layoutProvider. I will send the deeper details once we implement and test it.

For the workaround you can use Data Services Authorization on MODULE_READ rights. Users, that you do not want to see some module will see the module tab in the menu, but will not see models underneath.

Looking forward to present you our solution on the ‘Permission’ filed soon.

Hi @peter-sheer-arch

Thank you for clarifying the difference between PAC & PT and for posting status updates!

And thank you also for the workaround, but it sounds not suitable for our situation, as we want the module tab to vanish completely. The workaround sounds like it would only show a blank page to the user, but he can still see and access the tab.

we want the module tab to vanish completely. The workaround sounds like it would only show a blank page to the user, but he can still see and access the tab.

if you are in hurry and you use the module registration then you could also workaround that by doing a check on module registration:

// ./client/src/modules/index.ts?at=refs%2Ftags%2F202306.4.1#23
export const registerModulesOnLoginMiddleware = StoreFactories.createMiddleware((api, next, action) => {
  if (UaaActions.loggedIn.match(action)) {
    getAllModules().forEach(m => moduleRegistry.addModule(m)); //<-- here you have access to the modules appmodel 
  }
//..

if you are not creating module based app models yet then remember your single app model hand over is just plain json so you are free to rework the model before handover.
If you need a logged in state then cut the "content:{...}" of the model when handing over to app setup and add the whole model afterwards via addModule of awesome module registry

or better directly switch to the module based approach of client a12 (like shown in the modules folder of project template)

Hi @markus-agile-fog

Thank you for bringing up the module registry!

We already implemented a workaround using this and only registering modules if the users roles and roles of the app-model partially intersect.

Hi @raffael-broad-linden ,

we updated the Project Template the way, that it reflects permissions defined in the SME and AppModel modules. It is available in the freshly released Project Template 202306.5.1.

There are two changes done:

  1. The handling of permission itself. You can see the changes in:
  • client/src/pp/layoutProvider.tsx in lines 20 and 26
  • plus related utils in client/src/modules/utils.ts
  1. Filter of modules for the user. It prevents modules, that user have no permission for, from loading.
    The filter can be seen in:
  • client/src/modules/index.ts in lines 24,25 and 27
    And related changes in:
  • client/src/modules/spec.ts in line 17
  • client/src/appsetup.ts in line 66
  • intialActivity moved from client/src/appmodel.json to client/src/modules/person-appmodel.json to align with the module-based approach of the Project Template
  • plus related utils in client/src/modules/utils.ts

Our solution uses modifiedOidcUser action to get the user’s permissions and compare it with the Appmodel permissions.

Based on your question, there’s also an ongoing parallel activity to update the documentation with more information about the Permission field. Thank you for bringing this up!