Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope all queries beneath a tenant id #107

Open
caspiano opened this issue Jul 27, 2021 · 1 comment · May be fixed by #183
Open

Scope all queries beneath a tenant id #107

caspiano opened this issue Jul 27, 2021 · 1 comment · May be fixed by #183
Assignees
Labels
on ice Immediate attention is not required priority: low type: enhancement new feature or request

Comments

@caspiano
Copy link
Contributor

A new model Tenant or Organization should be added.
For queries, we can overload queries on the ORM to ensure that the tenant's ID is included.

@caspiano caspiano added the type: enhancement new feature or request label Jul 27, 2021
@caspiano caspiano added the on ice Immediate attention is not required label Jun 14, 2022
@stakach
Copy link
Member

stakach commented Aug 23, 2022

base this on the User model

belongs_to Authority
secondary_index :authority_id
validates :authority_id, presence: true

then uniqueness checks on models should be scoped to the authority_id (this is an example of that in User model)

ensure_unique :email_digest, scope: [:authority_id, :email_digest] do |authority_id, email_digest|
  {authority_id, email_digest}
end

The classes that should be scoped are:

  • zone
  • trigger
  • control_system
  • edge
  • broker
  • asset
  • module

optionally scoped: (authority_id can be nil)

  • repository (so we can have drivers shared)
  • driver

Things like metadata, trigger instances and settings don't need to be explicitly scoped as they are associated with things that are scoped

@chillfox chillfox linked a pull request Sep 5, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on ice Immediate attention is not required priority: low type: enhancement new feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants