Search code examples
liquidlooker

How do I capture the Looker User's Groups as an Additional Param (in JDBC/Snowflake Connection)


I am trying to pass the Looker User's Groups as an Additional Param in my Looker Snowflake Connection. This will help me to differentiate between customers and use cases for a shared user/role/connection to Snowflake.

I can't find any method of referencing the Looker User's Groups as a Liquid variable - https://cloud.google.com/looker/docs/liquid-variable-reference.

The only option that I have found so far is to create a Looker User Attribute, manually add the desired value into that User Attribute, then pass the User Attribute as an Additional Param in the Looker Connection.

My Additional Param for "customer_schema" from User Attribute "allowed_customer_schemas" looks like this, or customer_schema={{ _user_attributes['allowed_customer_schemas'] }}

References

The problem here is that this is a manual process, and it has an extra moving part (e.g. User Group -> User Attribute -> Additional Param); ideal resolution would be User Group directly into Additional Param.

How do I pass the User's Groups directly in the Additional Params field?


Solution

  • I haven't found anything to access the Looker Groups directly, which is frustrating. My workaround is to use a Looker User Attribute and set it up so that the Group Values section applies a value based on the group. Group Values wasn't in any documentation that I found, I was lucky enough to stumble onto it and have found it fairly useful as an all-purpose workaround and eliminates some of the manual entry for users.

    For example, if you have groups for Internal Customers, External Customers and Testing with the attribute allowed_customer_schemas you could set the Group Values as (Group/Value):

    1. Testing = testing
    2. External Customers = external
    3. Internal Customers = internal
    4. default value = external

    Each user in the group will have the values entered unless manually overridden on the User page. The order of the Group Values can be adjusted to apply in the correct sequence. For example, I have a group for Sales and a group for Managers. Managers are also in the Sales group, so their Group Values are first in the sequence so they take the correct value.

    When you set up (or edit) the User Attribute, the page has three small sub-headers for Definition, Group Values and User Values. You can set the Group Values then view how they are applied to individual users on the User Values where it will show all the applied rules and which group it is tied to.

    Note that if you want to have multiple values (Sales, Managers, Testing) for the attribute to set the Data Type to String Filter (advanced)

    Personal Experience: I use Group Values to assign attributes to Users as Access Filters, Access Grants, and Dashboard filters to span multiple scenarios and data access.