Trickle down multitenancy :bypass
I have an entry point for a resource that bypasses the tenancy
this resource preloads other tenanted resources returning an error
is there a way to pass down that context or should I create a non tenanted interface for each resource?
17 Replies
There isn't a way currently. I can see how inconvenient it would be, so maybe we can add a feature for it, but you'll have to work around it w/ separate actiosn for now
is the :bypass option part of the context?
It is not, no
would that be a good way to do it? I assume the context get's propagate through the whole chain of actions
It does not, but "shared" context does, which is new
Are you asking how we'd do it in core or how you'd propagate that down yourself?
yeah in case I want to open a PR
Gotcha, in that case yes that is likely how we'd do it 😄
are you able to point me where the actual tenant get used for filtering the query?
is it here? https://github.com/xantrac/ash/blob/main/lib/ash/actions/update/update.ex#L742
GitHub
provide the tenant: :bypass option that can be configured at runtim...
Contributor checklist
Leave anything that you believe does not apply unchecked.
Bug fixes include regression tests
Chores
Documentation changes
Features include unit/acceptance tests
Refactor...
following up on this @Zach Daniel what kind of interface would you like? https://hexdocs.pm/ash/dsl-ash-resource.html#actions-read-multitenancy
or
or
or else?
🤔 I think perhaps
:bypass_all
do we have a way to identify the top level action when we handle relationships? I want to avoid if go through an action with this option enabled it will cascade down even if not specified in the top level action
or at least being able to ask,
is_top_level_query
'context[:accessing_from]`
But I think whatever the rules are should be applied even if it's not the top level action
mmm that could lead to an unpredictable behavior though
so you think if an intermediate resources has a bypass all action, all the following cascading ones should bypass ass well?
It's not done at the resource level but at an action level
I see what you're saying though
So you're saying it would only apply to immediate children
is the simple bypass logic actually implemented for create and update? I can't find any test in regard
should I remove it from the docs?
this is r4r https://github.com/ash-project/ash/pull/2154
GitHub
provide the tenant: :bypass option that can be configured at runtim...
This PR allows the user to setup a new value bypass_all for the multitenancy option in the read action. With bypass_all the user can recursively bypass the tenancy of all the resources successively...