Data Masking in elasticsearch

I wanted to know is there any way we can achieve the below usecase from elasticsearch inbuild feature.

I have employee data indexed in elasticsearch search

EMP ID FNAME LNAME COUNTRY Organization Other 50 Attributes associated with Employee

1 Jayesh Bhoyar United States ABC
2 Tapan pal United States ABC
3 Ajay United States ABC
4 Ravi Verma Korea ABC
7 Pankaj Pal Korea ABC
5 Sundar Lal Japan ABC
6 rahul Sri Japan ABC

Now we have 4 users and their access level:

User1 - has access to USA
User2 - has access to USA, Japan
User3 - has access to USA, Korea
User4 - has access to USA, Japan, Korea

User 1

Now when User 1 search ABC he should get 7 results but output should be as follows:

EMP ID FNAME LNAME COUNTRY Organization Other 50 Attributes associated with Employee

1 Jayesh Bhoyar United States ABC
2 Tapan pal United States ABC
3 Ajay United States ABC
XXX XXX XXX Korea XXX XXXXXXXX
XXX XXX XXX Korea XXX XXXXXXXX
XXX XXX XXX Japan XXX XXXXXXXX
XXX XXX XXX Japan XXX XXXXXXXX

User2

Now when User 2 search ABC he should get 7 results but output should be as follows:

He should be able to see the Japan results and korean results should be masked

EMP ID FNAME LNAME COUNTRY Organization Other 50 Attributes associated with Employee
1 Jayesh Bhoyar United States ABC
2 Tapan pal United States ABC
3 Ajay United States ABC
XXX XXX XXX Korea XXX XXXXXXXX
XXX XXX XXX Korea XXX XXXXXXXX
5 Sundar Lal Japan ABC
6 rahul Sri Japan ABC

User3
Now when User 3 search ABC he should get 7 results but output should be as follows:
He should be able to see the Korean results and Japan results should be masked
EMP ID FNAME LNAME COUNTRY Organization Other 50 Attributes associated with Employee
1 Jayesh Bhoyar United States ABC
2 Tapan pal United States ABC
3 Ajay United States ABC
4 Ravi Verma Korea ABC
7 Pankaj Pal Korea ABC
XXX XXX XXX Japan XXX XXXXXXXX
XXX XXX XXX Japan XXX XXXXXXXX

Is there any way we can achieve this by script or span or something else which is inbuild in elasticsearch

Data masking, just as you exemplified, it is not possible with standard/official plugins, but you can filter out documents based on user access permissions by using X-Pack Security

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.