Page tree
Skip to end of metadata
Go to start of metadata

This article provides a basic overview of Data Permissions. In GoodData, a Data Permissions filter is a predefined parameter that is included in all queries submitted to the datastore by the user to which they are assigned. Based on an attribute defined in the logical data model of the project, Data Permissions filters can be used to filter the data that is displayed to the user. For example, Data Permissions filters can be configured to filter data by user identifier, job title, or region. This basic example shows how to create and assign Data Permissions.

Contents:

Data Permissions were formerly called Mandatory User Filters.

For a step-by-step tutorial on setting up Data Permissions filters, see Getting Started with Data Permissions.

Data Permissions are generally applied at the highest table of a data model. Suppose you want to filter the data model by an attribute named Client Name. A Data Permissions filter needs to be created for each instance of this attribute. If the dataset includes two companies, Business A and Business B, then each company requires its own attribute value.

Methods

This article utilizes the gray pages for creating and deploying the Data Permissions.

For the implementation of Data Permissions across a large number of projects, however, you should use the GoodData APIs, which enable deployment of changes across multiple projects in a programmatic fashion.

By way of introduction, however, please complete the steps in this article to learn the basic process.

Basic Approach

The following basic steps need to be executed in this order to create a new Data Permissions filter and to apply it to users in the project:

  1. Get the object identifier of the attribute on which to filter.
  2. Get the object identifier of the field value (element) of the attribute on which to filter.
  3. Execute code to create the Data Permissions filter.
  4. Locate the identifier of the user to which you wish to apply the filter.
  5. Execute the code to apply the filter to the specified user.
  6. Repeat the last two steps to apply the Data Permissions filter to other users.
  7. Repeat all of these steps to create and apply additional Data Permissions.

Creating the User Filter

 In the sections below, URLs reference the domain https://secure.gooddata.com.

Identifying the filtering attribute

First, find the ID for the Attribute you want to use as the filter:

https://secure.gooddata.com/gdc/md/{project-id}/query/attributes

Search this location for the title of your attribute. Click the name to get more information.

The last set of digits of the web address is the object identifier for the attribute. Write down this value.

Example:

https://secure.gooddata.com/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/49857

The above indicates the attribute to use, and the object ID is 49857.

In the same location, around the fourth grouping of code is a link for elements:

https://secure.gooddata.com/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/49858/elements

Click the link to the Elements page. On the Elements page, you can scroll down and find the field you want to filter.

Example:

In our example, we want to filter only Company data. Locate the data element value and write down the identifier.

title: Company Corporation
uri: /gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/49857/elements?id=1207166

In the above, the ID for this data value is 1207166.

Creating the filter

Next, you must create and execute the code to create the filter.

Go to the following address:

https://secure.gooddata.com/gdc/md/{project-id}/obj

Below is the code to run. For Content Type, use JSON:

{
	"userFilter": {
		"content": {
			"expression": "[/gdc/md/PROJECT_ID/obj/OBJECT_ID]=[/gdc/md/PROJECT_ID/obj/OBJECT_ID/elements?id=ELEMENT_ID]"
		},
		"meta": {
			"category": "userFilter",
			"title": "Example"
		}
	}
}


Example:

For our example, the code to use is listed below. The Object ID for the attribute on which to filter and the Element ID for the data value you want filtered have been inserted into the value for expression.

{
	"userFilter": {
		"content": {
			"expression": "[/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/49857]=[/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/49857/elements?			id=1207166]"
		},
		"meta": {
			"category": "userFilter",
			"title": "My Filter"
		}
	}
}

When the request is submitted, the GoodData platform returns a single line containing a URI. Click the link to confirm that the filter has been created and to retrieve the identifier for the filter, which is the last set of digits in the web address.

Example:

https://secure.gooddata.com/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/91074

In the above, the ID for this user filter is 91074.

Dashboard refresh

To ensure that the filter has been populated across the entire project, load an instance of a project dashboard in the GoodData Portal, and then select Refresh in your browser.

Assigning the Data Permissions filter to a User

Now, you must assign the filter to a user. Go to this address:

https://secure.gooddata.com/gdc/md/PROJECT_ID/userfilters

Example:

For our example, the address to use is the following:

https://secure.gooddata.com/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/userfilters

The above opens the user filter submission page, where you can locate the identifier of the user on which to filter. The user list is available in the gray pages:

https://secure.gooddata.com/gdc/projects/PROJECT_ID/users

Example:

For our example, the address to use is the following:

https://secure.gooddata.com/gdc/projects/zv8jkbo050hq9qeqwgzbsor550mf8mxy/users

The user list for the project is displayed. Here, you can search for the users to which you wish to apply the filter.

For each user, you want to copy and paste the corresponding text that goes with the self link. Keep this link handy:

/gdc/account/profile/70a966022bce7b4822a9a310a1919c03

In this example, this link is the one to use to filter the data for the user.

Submit filter request

Finally, the filter request must be submitted to GoodData. Go to this link:

https://secure.gooddata.com/gdc/md/PROJECT_ID/userfilters

In the User text box, paste the link from the self link above. Example:

/gdc/account/profile/70a966022bce7b4822a9a310a1919c03

The following code needs to be submitted in the UserFilters section. If you are using the GoodData API, use a POST request with following payload:

{
	"userFilters": {
		"items": [
			{
				"user": "/gdc/account/profile/USER-ID",
				"userFilters": [
					"/gdc/md/PROJECT_ID/obj/USER-FILTER-ID"
				]
			}
		]
	}
}

Example:

For our example, here’s the code:

{
	"userFilters": {
		"items": [
			{
				"user": "/gdc/account/profile/70a966022bce7b4822a9a310a1919c03",
				"userFilters": [
					"/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/91074"
				]
			}
		]
	}
}

This code assigns user 70a…c03 to the filter 91074. When submitted, the response should indicate a success or an error.

{
	"userFiltersUpdateResult": {
		"failed": [],
		"successful": [
			"/gdc/account/profile/PROFILE-ID"
		]
	}
}

Multiple filters can be assigned per user at once.

To use the gray pages, you just need to input the User URI and Filter URI to the input fields:

User:

/gdc/account/profile/70a966022bce7b4822a9a310a1919c03

Filter:

/gdc/md/zv8jkbo050hq9qeqwgzbsor550mf8mxy/obj/91074

Insert each user filter as a separate line. See another example on the screenshot below:

That’s it. Data is filtered for the specified user, using the Data Permissions filter you created.

This technique can be used to perform filtration of data for a wide variety of use cases. Please note that these filters are ALWAYS applied to queries submitted by the users to which they have been assigned.

For more information about Data Permissions, see Powered by GoodData Quick Start - Create Data Permissions.