samoloth

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

zachdaniel

Creator of Ash

Just coming back from vacation. Also busier than ever :slight_smile:

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

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

samoloth

I meant global admin that could manage all resources, impersonate users from different organizations and so on

Last Post!

zachdaniel

zachdaniel

Creator of Ash

I was referring to the discord server, not the forum.

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement