Laravel如何实施同一服务的多个实例

发布于 2025-02-09 17:23:56 字数 809 浏览 1 评论 0原文

当前的设置:

角前端应用程序访问和编辑数据 laravel后端。 用户身份验证是通过Laravel Passport处理的。

问题:

多家公司应该能够使用自己的数据(可能是他们自己的数据库)获得自己的“副本”此服务的“副本”。

我可以想到的选项:

  1. 克隆Laravel的实例,用于注册的每个新公司(Docker已经设置了)。添加Laravel登录实例,该实例容纳一个查找表,以确定哪个电子邮件属于哪个后端实例。登录实例返回Docker域/端口和身份验证。

  2. 将公司字段添加到当前Laravel项目中的每个表中。调整代码仅返回用户属于的项目的数据。

目标:

  1. 安全性:不应从其他客户/公司访问或编辑数据。
  2. 许多人对许多人:最佳地,一封电子邮件应该能够与多个客户/公司帐户联系起来。
  3. 只有1个角前端。当前,它拥有一个api_url字段,我手动更改该字段以访问不同的Laravel后端(DEV,PROD)。
  4. 一个登录名,我不想拥有将我链接到正确后端的公司登录名,然后必须输入选定的后端的另一个登录名。即一个身份验证,如果例如登录节点只是返回发送实际验证请求的位置,这应该不是问题。

我已经经历了一段时间,我无法决定一种特定的方法。 欢迎任何指导,技巧,替代方案或陷阱

The Current Setup:

Angular front-end application which accesses and edits data on a Laravel backend.
User authentication is handled via Laravel Passport.

The Problem:

Multiple companies should be able to get their own 'copy' of this service with their own data, possibly their own database.

Options I can think of:

  1. Clone Laravel instance for each new company that signs up (docker is already setup). Add Laravel Login Instance which holds a lookup table to determine which email belongs to which backend instance. The login instance returns docker domain/port and authentication is handled there.

  2. Add Company Field to every table in the current Laravel project. Adapt code to only return data for the project the user belongs to.

Goals:

  1. Security: It should not ever be possible to access or edit data from another customer/company.
  2. Many to Many: Optimally, a single email should be able to associate with multiple customer/company accounts.
  3. Only 1 Angular frontend. Currently, it holds an api_url field which I manually change to access different Laravel backends (dev, prod).
  4. One login, I don't want to have a company login that links me to the correct backend, and then have to enter another login for the selected backend. i.e one authentication, this should not be a problem if for example the login node just returns where to send the actual auth request.

I have been going through this for a while now and I can't decide on a specific way of doing it. Any guidance, tips, alternatives, or pitfalls are welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极致的悲 2025-02-16 17:23:56

正如Peppermintology所建议的那样,我尝试了 laravel 租赁,这只是可行的。
他们提供配置,用于为每个租户使用单个数据库或数据库以及许多其他功能。

As suggested by Peppermintology, I tried Tenancy for Laravel and it just works.
They offer configuration to use a single Database or A Database for each Tenant, along with a lot of other features.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文