AL icon indicating copy to clipboard operation
AL copied to clipboard

Base application triggered Event Subscriptions and Permissions Property

Open Frantic42 opened this issue 8 years ago • 10 comments

Issue:

When using Event Subscriptions in an app extension that are triggered by base application areas, a normal user without an assigned app permission set will be thrown an error when the codeunit reads from an extension table. Even after blanket adding indirect permissions for the Permission Sets that the user does have assigned (as suggested in https://github.com/Microsoft/AL/issues/1389 ), and adding the appropriate Permissions property to the event subscriber codeunit, the error will still be thrown deeper in the call stack when tables are read from other objects without the Permissions property.

To Reproduce:

  1. In an extension, have a codeunit with an event subscription to table 27 Item, OnAfterModify

  2. Add the Permission property to the codeunit for an extension table giving Read access (or even RIMD)

  3. Have the subscription trigger call a function in a second codeunit which does not have the Permissions property set to read the table

  4. Have the function in the second codeunit do a GET on the extension table

  5. Add Indirect read permission for the extension table in the permission set 'D365 BUS FULL ACCESS'

  6. Create a new user using: New-NavContainerNavUser -containerName -credential -PermissionSetId 'D365 BUS FULL ACCESS'

  7. Log on as the new user

  8. Open the Item Card and modify an Item

  9. Permission error is thrown

Expected behavior: Options...

  1. Prefered behaviour is as has always worked, adding permissions to the Permissions property adds that permission for all subsequent oeprations in the call stack without requiring Indirect permission as part of a Permission Set.

  2. Whilst not understanding the direction being taken with the new Indirect permission requirement, I can suggest that in line with this it might be possible to fix it so that if both the Indirect permission requirement is met, and the codeunit's (or other object's) Permissions property requirement are met, then subsequent operations in the call stack would not require that the current object also have that Permissions property for the table being checked. I got 3 codeunits deep before realising that the only way forward would be to add all encompasing Permissions properties to all objects in our extension.

  3. It would be nice to have a new property for an object that indicates that the Indirect permission requirement doesn not need to be met. In order to fulfil this requirement, I wrote a workaround to basically insert/update indirect permissions for all our extension tables into every permission set during publish/recreate, and added an event trigger to Permission Set OnAfterInsert to also create these permissions for any new Permission Sets.

  4. Perhaps ignore some permission requirement in event subscriber functions. The actual issue I'm tasked with solving is that critical event subscriptions for the Item table must run to prevent database inconsistency, even if the app has not been opened up for all users.

  5. Perhaps a universal Permission Set that app extensions can add indirect permissions to, to save having to generate them for all Permission Sets.

Version:

bcsandbox Microsoft_Application_13.0.24630.24844 Microsoft_System_13.0.12929.0.app

Sorry for being long winded here. Thanks in advance for any feedback or cleaner workarounds. Hopefully I'm just missing something obvious.

Mark Smart

Frantic42 avatar Oct 19 '18 16:10 Frantic42

Would it be possible for someone to look into this? It's really a dealbreaker for our app and we can't move forward. I'd be happy to provide any information anyone requests.

Frantic42 avatar Oct 23 '18 15:10 Frantic42

We currently have a large backlog of issues but will look into it soon. If you require urgent support please contact the regular support channel. There was a recent change in permissions behavior related to this issue: https://github.com/Microsoft/AL/issues/3108

StanislawStempin avatar Oct 23 '18 15:10 StanislawStempin

Could you provide a sample AL code that results in what you believe is incorrect behavior? Based on the description of the issue we believe the system behaves as intended but it's important for us to understand the details so source code will be the most precise way to do it.

StanislawStempin avatar Oct 25 '18 07:10 StanislawStempin

Ok, I've created and tested a simple extension that you can use.

ACME Descriptions.zip

After installation, create the ACME Setup record with blank Primary Key, and set Harvest Descriptions to Yes.

  1. Login as admin (SUPER user), and modify an Item's description. Code will run without issue. (Good.)

  2. Create a user that does not have SUPER. Give them a Permission Set that allows modifying items, but no specific permissions to tables 6000001 and 60000002. Login as this user, and try to modify the Description on an item. Error will occur immediately in the ACME Event Subscription codeunit. (Workable if by design, but does immediately break the system upon install unless indirect permissions are added to all Permission Sets during install).

  3. Create a second user that does not have SUPER. Create a new Permission Set for them copied from the permission set used by the first user. Add to this new Permission Set indirect permissions for tables 6000001 and 60000002. Login as this user, and try to modify the Description on an item. Code will run without issue in the event subcriber codeunit, but will throw a permission error in ACME Description field validation. (Bad, should inherit the permission from the codeunit. Hopefully not by design, as the only way around this is to add the Permissions property to all objects in the call stack.)

Frantic42 avatar Oct 26 '18 09:10 Frantic42

Agree, looks like a bug to me too. I need some clarification though.

kalberes avatar Nov 21 '18 14:11 kalberes

Agree, looks like a bug to me too. I need some clarification though.

What do you need?

Frantic42 avatar Nov 21 '18 14:11 Frantic42

The behavior you describe is by design and as far as I am aware this is how it has always worked.

Indirect permissions does not involve any ‘stack walk’, so downstream callers do not inherit the permissions that an upstream object has. If this was the case then any subscriber to e.g. an event on a code unit, would inherit the indirect object permission.

Rather, indirect permissions should be interpreted as a 'view' on data: User can only see the data through the ‘view’ that the codeunit or page provides if they have access to codeunit exposing the view and at least indirect permissions to the table data.

Hence the user with only indirect permission will not have access to the data if subsequent code reads data without going through ‘the view’.

jensmpmsft avatar Nov 23 '18 13:11 jensmpmsft

Thanks for repairing this. I look forward to testing this in the December update.

Frantic42 avatar Nov 23 '18 14:11 Frantic42

The bot applied incorrect label. If you read Jens' reply he mentions that the behavior is by design.

StanislawStempin avatar Nov 23 '18 16:11 StanislawStempin

In that case, I feel I must reiterate the issue. It is not regarding the behaviour of indirect user permissions, rather the behaviour of the permission property of objects. Our implelemtation code already generates and maintains indrect permissions for the entire extension.

I created a quick test case in classic Navision (5.0.26084) and the behaviour is identical to the current build and therfore by design as you have stated.

I guess that this has never been an issue in customised systems. I will code around this somehow.

Frantic42 avatar Nov 23 '18 16:11 Frantic42