module-defined schema permissions

LabKey Support Forum (Inactive)
module-defined schema permissions Ben Bimber  2015-05-21 07:32
Status: Closed
 
Hello,

Can you say a little more about your scenario? You basically want row-level control over read access, based on createdBy? If so, here's a trick we've combined with linked schemas to accomplish something like that. In our case I needed more access than just the single user, so this example is one step more complicated:

- we have a table of data with a column for 'project' (think of this like the client) and a createdby field
- we have a second table with 2 columns: 'user/group' and 'project'. this table has rows that list which user(s) or group(s) have access to each project.

It sounds like your source table has a createdby column, mapping back to a Labkey userId? In our case, createdBy, plus a subselect between the project and the table above will produce a whitelist of user/group IDs with access to that row. If you only care about the createdBy user having access, this whole second table thing can be ignored.

In Labkey SQL, there is an isMemberOf(int) function. this is the key. wrap your data table in a query like:

select * from myTable t WHERE isMemberOf(t.createdby)

or

select * from myTable t WHERE isMemberOf(t.createdby) OR (select count(*) from mappingTable m WHERE m.project = t.project and isMemberOf(m.userid)) > 0

then share this query, which will only ever have the rows belonging to the current user. you can tweak the WHERE clause to match the behavior you want.

Note: if you're willing to learn, a custom java TableInfo would let you introduce dynamic filters as well.

-Ben