emoss08 / Trenova

An Open Source AI-driven asset based transportation management system
http://trenova.app
Other
24 stars 5 forks source link

Use Ent Privacy Option for Multi-Tenancy #238

Closed emoss08 closed 3 months ago

emoss08 commented 6 months ago

Implement multi-tenancy using a Ent Privacy Option .

Specifically we should look at the Ent Privacy Multi Tenancy example .

Right now, on each of the controllers, we're simply retrieving the Business Unit and Organization ID from context. Shown in the example below.

userID, ok := r.Context().Value(middleware.ContextKeyUserID).(uuid.UUID)
buID, ok := r.Context().Value(middleware.ContextKeyBuID).(uuid.UUID)
orgID, ok := r.Context().Value(middleware.ContextKeyOrgID).(uuid.UUID)

Once these are grabbed we then pass these into services that query the database for the proper results. Of course, this is more of a controlled approach ,but the policy will do the same thing.

This will likely extend into us adding policies that control rbac to ensure the user can only see information based on their role within the application.

emoss08 commented 5 months ago

This has been started.