Multi tenant / multi subdomain

hi,
we are developing a multi tenant application which we intend to host in house.
main website would be used for initial user signup and and signin but after initial signin we would like to redirect our users to their private tenant which would be hosted under clientX.domain.com.
what is the best way to deal with authentication from this perspective? keep in mind that all ui’s will be developed in weweb using weweb integrations; right now we do supabase.

thank you
P

Hi there :waving_hand:

This question is a bit advanced for me so I’ll pass it down to our tech team.

Edit: This question has been solved on support chat.

1 Like

no, it was not. but thank you.

You gotta self host and use a Proxy

i am selfhosting. what do you mean by proxy? how would that help ?

Read about how proxies work and you’ll find out they allow you to route traffic in different ways.

i know how a proxy works, i was asking how would it help in this situation. we basically need to move weweb’s “is_authenticated” from one subdomain to another.

I see, that won’t work. It’s not a WeWeb thing, but rather a browser thing. If you’re redirecting between domains, you could send the credentials via a query, but it’s very clunky and potentially not secure. I think you should handle auth per domain.

exactly. i cant do query because of security. what do you mean auth per domain? can you share a doc ?

What you’re trying to do is not documented anywhere specifically within WeWeb. I think the simplest way would be to just not share the Auth between the pages, which in theory could be the default scenario.

I actually just started developing a multi tenant app myself this week. Though I decided against using WeWeb for this use case so I could use https://usebasejump.com/ with its components. Maybe you can take some inspiration from their docs.

setup your colours and logos etc for each tenant on a database table.

Use CoAlias to manage the domains. https://coalias.com/

You don’t want to send authentication via query as it would leave your user vulnerable to impersonation by simply sharing an URL, but you might be able to set the auth cookie for the sub-domain while still on the domain page (set Domain=.example.com with a dot prefix to apply to all sub-domains). I guess you would need control over the back-end to set cookies like that, or maybe you could do it with custom javascript on the auth workflow response.