Imagine that you have a large monorepo code base running as a monolith application. This application is backed by a database. Some of the data in the database is sensitive, so you want to restrict access to it to decrease the risk of developers mis handling it. Essentially, you only want to allow specific chunks of code that have been approved to access this data. What would be a good way to do that?
A couple ideas I had are:
- Lint rule to prevent unrestricted import of the data access objects. The downside of this is this does not work at runtime.
- Vending the sensitive data via a method that requires an API key. This could be used in conjunction with the import lint rule. The downside of this is that in a monolith/monorepo, it's probably pretty easy to access any auth material so developers might end up sharing API keys to gain access.
- Having developers register their callsites and then using an inspection library to determine that the callsite requesting sensitive data is registered. This one seems very fragile and tightly coupled.
Any other ideas or potentially enhancements to these ideas?
There's always going to be workarounds that I don't think can be solved like developers who already have access sharing it for other use cases. I guess you'd have to rely on some developer trust there.
Lastly, this all assumes that you can't directly access the database easily.
Thanks everyone.