Actor can create data in other tenant
I'm testing wether a member of TenantA can create a project in TenantB. This test is failing (the :create is succeeding).
I thought that multitenancy would block this case, but perhaps I'm confusing things.
Following here are some snippets of the setup.
the resource (skipped parts)
9 Replies
Some more snippets for context
create the tenants
create the member
I think the most important snippet would be the
create_project
snippetOh sorry, here it is:
the tenant will only set the attribute to the tenant value, but you need to setup the policies yourself
So if I understand correctly, without a :create policy, my multitenancy block only sets the field but does not prevent inserting anything?
Regarding a simple "actor_in_tenant" policy, would this be correct?
The concept isn't easy to grasp at first 👼
you probably don't want to do a query in your policy, as this could lead to a lot of queries being fired.
Most often all the necessary data on the actor is loaded in a plug before setting it, that way you only load it once and can just do a simple comparison
I see, thanks for the hint. It appears my actor already contains the memberships:
So the following also works:
Is that correct? I wonder if the memberships will be present when used with AshJsonApi. I set the tenant and actor there like this:
I'm afraid of overlooking / overestimating some of the magic now that is provided 😊
Ah, I have a
change manage_relationship(...)
in my User.create action:
I guess that explains, why the memberships are present.you probably want to add a load there
that would do it, I would still add the load, just for completeness sake
Thank you very much!