samoloth
What is the recommended way to add an admin account in multi tenant setup?
Hi! I’ve just started using Ash due to its multitenancy capabilities. Overall experience is great so far, but I am considering following scenario right now.
- there are multiple organizations, which data lives in separate schemas (context based multitenancy)
- each organization has its own users and tokens tables
- signing in is quite straightforward when current tenant is being fetched from subdomain
But what is the recommended way of adding admins right now? The only way I see is to create another resource called `Admin`, but what about AshAuthenticationPhoenix views and routes? If I’d use different strategies, the UI should be different. What about impersonation? Am I missing something?
Most Liked
zachdaniel
Just coming back from vacation. Also busier than ever ![]()
Typically you would create a separate resource that uses ash_authentication just like your user resource, as per your first message.
This sort of thing can get complex because how you write your policy logic needs to handle cases where the actor is an %Admin{}. But we’ve done the same thing in my current application. For masquerading, we do that with magic links and a special action that generates a magic link with a custom claim set.
You can control using options in your auth routes what resources to add route for, so you can have like /admin/sign-in etc.
I’d suggest asking around in the discord/searching there if you don’t get what you’re looking for here.
christhekeele
Welcome to the forum!
I can’t answer your question, but for clarification when a more Ash-skilled person comes online, are you asking about tenant-admins (a role for a tenant user capable of doing more within an org) or cross-tenant admins (a login for a system operator to access cross-org controls)? From your question about impersonation, I’d assume the latter, though I have seen single-tenant admin impersonation before.
samoloth
I meant global admin that could manage all resources, impersonate users from different organizations and so on
Last Post!
zachdaniel
Popular in Questions
Other popular topics
Latest Ash Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









