Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
avatar
Cloudera Employee

In this article, the requirement is to have simple tag names that will be applied to attributes in a Hive table.

Here, tags such as “Hashed” and “Masked” will be used in many tables. Different groups may need access to the data in the clear, while others will not be granted access. The opposite may apply for a different table.

 

Table name atlas_tag_test has the columns ssn that will be shown for hr_users and masked for power_users.

 

  • The value will be a comma-separated list of groups, in this case, we only have a single group.
    001.png
  • Now in Ranger, we have a policy for masked.
    002.png
  • For each group we are adding a condition, we check if power_users are set in the group's attribute like the following:
    if ( ctx.getAttributeValue("Masked","groups").indexOf("power_users") !== -1 )
    { ctx.result = false; } else { ctx.result = true; }

 

 

  • If it is, the data will be available to the user to see in the clear. It is not, the users will not be able to see the data.
    003.png

 

  • We will add another row for hr_users like the following:
    if ( ctx.getAttributeValue("Masked","groups").indexOf("hr_users") !== -1 )
    { ctx.result = false; } else { ctx.result = true; }
    004.png

 

  • When selecting the data with a power_users, the data is masked:
    005.png

    006.png
  • When executing with hr_users, the data is displayed as un-masked:007.png
    008.png
  • We can see for the power_users that the masked policy was applied to matching number 85:009.png

 

 To dig deeper into it what additional functions are available you could also review the source code in GIT.

541 Views
0 Kudos