I need to design and implement a RBAC (role based access control) library to protect RPC calls. A role is a list of verbs (RPC methods). One should be able bind a user (or group of users) to a role over a resource (or group of resources). The architecture needs to scale to 10^8 users and 10^8 resources.
I thought of having int64 unique identifiers for users and resources. I'd store group hierarchy, role binding and users and resources in a SQL or NoSQL database. Then I'd use Apache Spark to flatten (user, role, resource) tuples which I'd store somewhere I'd query quickly, like ElasticSearch.
I'm pretty sure this design scales. However, it is not clear how I'd handle group membership changes and role unbinding.
Any suggestions on how to make sure changes above won't leave lingering (user, role, resource) tuples?