J
J
JayBerkutie2021-02-15 22:28:13
Laravel
JayBerkutie, 2021-02-15 22:28:13

How to make authorization in an application with multiple databases?

There was a task to remake the authorization system in the application.
Now the base of each organization is deployed on separate subdomains and it all looks like this
602aca8c1725d574522656.png

Now, everything needs to be redone to such a form that access to all bases was through one subdomain.
602acab96f45f303944995.png

The question arises how to make a request to check the existence of a user in all databases during authorization? The number of bases is planned to be increased. A user can simultaneously be in several databases at the same time.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JhaoDa, 2021-02-16
@JhaoDa

Create a custom implementation of the UserProvider contract , in which "make a request to check the existence of the user in all databases."

K
Konstantin B., 2021-02-16
@Kostik_1993

I would advise you to unite and transfer users to another database, if you have them and since they are shit. It will be much more elegant than it is now, especially since you are planning their growth.
By the way, apparently you now have an incorrect architecture that needs to be reworked, in your case there is a violation of normal forms.
According to the idea, you should have something like this
users - A table of all users organizations
- all companies you specify what role your user has in this particular organization, that is, the fields are user_id, organization_id, role_id

Well, etc., for example, let's take some other type of data, let it be services provided by an organization, then they will have a services table with an organization_id field and other fields
In general, everything is quite simply distributed
udivlennyj-bagz-banni-mem-shablon.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question