This is an example of how you can use RBAC and the CURRENT_SECURITY_GROUPS function to implement data hiding in SingleStore.
- Get a SingleStore free license key from https://portal.singlestore.com
- Set your SingleStore license key as an environment variable
export LICENSE_KEY="PUT YOUR LICENSE KEY HERE"
- Run SingleStore cluster in a box
docker run -it \
--name memsql-ciab \
-e LICENSE_KEY=$LICENSE_KEY \
-e ROOT_PASSWORD='p' \
-p 3306:3306 -p 8080:8080 \
memsql/cluster-in-a-box
- Download and run hiding.sql
mysql -u root -h 127.0.0.1 -pp < hiding.sql
This is BOB, the operator. He can only see the last 4 of the social security number
+-------------+-------+---------+---------------------+-------------+
| customer_id | fname | lname | dob | ssnumber |
+-------------+-------+---------+---------------------+-------------+
| 2 | dale | deloy | 2000-10-01 00:00:00 | xxx-xx-1234 |
| 1 | matt | demarco | 2000-01-31 00:00:00 | xxx-xx-6789 |
+-------------+-------+---------+---------------------+-------------+
---
This is ALICE, the manager. She can the ENTIRE social security number
+-------------+-------+---------+---------------------+-------------+
| customer_id | fname | lname | dob | ssnumber |
+-------------+-------+---------+---------------------+-------------+
| 2 | dale | deloy | 2000-10-01 00:00:00 | 198-12-1234 |
| 1 | matt | demarco | 2000-01-31 00:00:00 | 123-45-6789 |
+-------------+-------+---------+---------------------+-------------+