设计用户单表登录以在子域中使用 [英] Design users table for single sign in to use across sub domains

查看:142
本文介绍了设计用户单表登录以在子域中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个网站,其子域名如下:


  1. example.com - 主要网站

  2. food.example.com

  3. fashion.example.com

每个域和子域都有一个不同的数据库,如下所示:


  1. exampleDB / em>

  2. foodDB

  3. fashionDB

您尝试了什么?


  1. 现在,单点登录我们计划重定向用户在我们的主要网站上注册。


  2. 虽然子域中的订单处理从主数据库获取UserID,并存储在相应子域的订单表中。 >


  3. 为了报告,我们存储 UserID 而不使用 FK约束 Orders 表,因为我们有单独的数据库。


我可以看到这里堆栈交换站点有单独的数据库,但是它有单独的用户表格?



StackExchange网络配置文件是否存储在单独的数据库中?



我可以从这里每个网站的用户表都有StackExchange网络配置文件的AccountId。



示例:


  1. 这里是Nick Craver网络个人资料,编号:7598


  2. 他的个人资料在历史记录网站中具有与同一ID相关联的帐号:7598检查查询。


中的任何地方,我看不到帐户数据愚弄,所以是 AccountId 存储?如何使用 AccountId 在多个网站上完成SSO?



我的问题:我们在主数据库中需要一个用户表,或者我们必须为子域的数据库和 Link Main DB UserID 而不是FK约束创建单独的用户表。



任何帮助都会很棒。

解决方案

您提到的UserID在单个DB中的特定Users表中只相同。它实际上不是您域中任何用户的标识符。要识别多个数据库中的用户,您需要为每个用户提供域级别的ID。一个简单的方法是添加一个名为UID的属性(列)或类似于User Class(table)的全局唯一ID(GUID,请参阅 https://msdn.microsoft.com/en-us/library/system.guid(v = vs.110)。 aspx ),并将其用作域级ID来标识用户而不是UserId。通过这种方式,您可以将用户信息自由存储在您域中的多个数据库中所以:




  • 您可以在每个子域的数据库中只保留域级ID,并使用该ID从主要查询完整的用户配置文件域DB。优点:成本较低记忆力。权衡:在分布式系统中,由于信息驻留在主数据库中,从子域查询用户信息需要更长时间。

  • 可以在所有数据库中保存完整的用户信息,包括主要和次要。 Pro:查询速度更快缺点:成本更高,用户信息更改时,您必须在所有数据库中进行同步。


We have a site which has sub domains like:

  1. example.com - Main Site
  2. food.example.com
  3. fashion.example.com

And each domain and sub domain has a different database, like this:

  1. exampleDB - Main DB with Users Table
  2. foodDB
  3. fashionDB

What have you tried?

  1. Right now, for single sign in we have planned to redirect users in our Main Site for signing up.

  2. While order processing in sub domains get the UserID from main DB and store in respective sub domain's Orders table.

  3. For reporting purposes we store the UserID without FK constraint in the Orders table since we have separate database.

I can see here that stack exchange sites have separate databases, but does it have separate users tables too?

Does StackExchange Network profile is stored in a separate database?

I can see from here that Every site's user table has AccountId of StackExchange Network profile.

An Example:

  1. Here is Nick Craver Network Profile with ID:7598

  2. His profile in History Site has Account ID Linked with same ID:7598 check this query.

I can't see the Accounts table anywhere in data dumbs , So Were is AccountId stored? And how is SSO done in multiple sites using AccountId ?

My Question: Do we need a single user table in Main DB or we have to create separate user tables for the sub domain's database and Link Main DB UserID but not FK constraint? Which is the best design for a shopping site?

Any help would be great.

解决方案

The UserID you mentioned is only identical in a specific Users table in a single DB. It's actually not an identifier of any user in your domain. To identify users across multiple databases, you will need a domain-level ID for every user. A simple way is to add one more property (column) named UID or something like that to User class (table), of Global Unique Id (GUID, see https://msdn.microsoft.com/en-us/library/system.guid(v=vs.110).aspx) and use it as domain-level ID to identify users instead of UserId. This way you can freely store user information in multiple databases in your domain. So:

  • You can hold only domain-level ID in every sub-domain's database and use that ID to query full user profiles from the main domain DB. Pros: costs less memory. Trade-off: in a distributed system, it takes longer to query user information from sub-domain because the information residing in main DB.
  • You can hold full user information in all DB, including main's and subs'. Pro: faster queries. Cons: costs more memory and when a user information changes, you will have to synchronize it across all databases.

这篇关于设计用户单表登录以在子域中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆