duanleiliu7373 2016-10-11 17:46
浏览 118

当每个租户在laravel中有多个用户时,如何在多租户网站中对用户进行身份验证

NOTE: I posted the same question yesterday but with different explanation, now I am editing it completely and trying to explain my point from a different aspect.

I am trying to implement authentication process for a multi-tenant site where we will have different companies registered for example: company 1, company 2 and etc and each company will have multiple users like company 1 will have User1, User2 and so on.

Here, I am using separate database for each company due to some strong reasons. I want the user to visit the site and just authenticate himself without using any separate domain. There will be a different domain for each company (e.g company1.mysite.com), but the user will be redirected to his respective domain after login.

So, my question is, how can I authenticate each user from his respective database at the time of login?

Thank You

  • 写回答

1条回答 默认 最新

  • dongmijgnnq0118 2017-03-15 00:24
    关注

    At the end of the day, you simply cannot ping all DBs fetching the users and hoping for a match. I would, however, recommend the following:

    A special mapping DB that holds users and their respective company database. For added security, you can treat emails like a password, storing an encrypted version with a predefined salt and when a user enters their email to login, a lookup is done against the mapping DB using the two encrypted email addresses. You will need to be careful to keep this DB synced well. If your DBs are on the same server, I might recommend insert and update triggers.

    At the point of successfully​ authenticating against their company DB, you would want to store the DB name in the user session to keep from ongoing lookups against the mapping DB. You could alternatively use the subdomain mapping to DB after successful auth.

    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程