Webpart permissions per user or group

LabKey Support Forum
Webpart permissions per user or group Matt V  2019-05-14 09:59
Status: Closed
 

Hello,
I'm creating a few new webparts and we need to limit who can see them. The permissions matrix (https://www.labkey.org/Documentation/wiki-page.view?name=webpartPermissions) has usually done the trick, but in this case it would be incredibly useful (borderline necessary) to be able to limit their display to groups or even specific users if groups aren't an option.

Is there a way to do this, even at a code level?

 
 
Jon (LabKey DevOps) responded:  2019-05-29 21:41
Hi Matt,

You should be able to leverage the Javascript API to identify the user's permissions and then choose to display an embedded webpart within a Wiki to accomplish this.

Take a look at the following docs, especially the tutorial that goes over "Step 4: Summary Report for Managers", which leverages a Security API call to determine the groups the user is apart of and then renders the report if the groups check out.

https://www.labkey.org/Documentation/wiki-page.view?name=viewApis
https://www.labkey.org/Documentation/wiki-page.view?name=javascriptTutorial
https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.Security.html

I recommend following the tutorial to see how it works first and you should be able to figure out how to adapt it for your specific needs.

Regards,

Jon